Skip to content

feat(run): propagate the run session as an x-session-id header (ENG-3473) - #1013

Merged
aix-ahmet merged 1 commit into
developmentfrom
ENG-3473-session-id-header-propagation
Jul 30, 2026
Merged

feat(run): propagate the run session as an x-session-id header (ENG-3473)#1013
aix-ahmet merged 1 commit into
developmentfrom
ENG-3473-session-id-header-propagation

Conversation

@elsheikhams99

Copy link
Copy Markdown
Collaborator

Runnable resources can already carry a per-run caller identity as
x-user-id; add the run's session alongside it so downstream services can
correlate a call with the conversation that triggered it.

  • _headers_for_run emits identifier -> x-user-id and session_id ->
    x-session-id as independent keys: either alone is valid, and with
    neither present it still returns None so no headers are attached.
  • session_id is header-only for every runnable (unlike identifier,
    which Agent keeps as an execution-config body field), so the base
    _RUN_CONTROL_KEYS excludes it; Model/Tool repeat it in _SDK_ONLY_PARAMS to
    also cover the v1 and URL builder paths.
  • Declared on ModelRunParams, not BaseRunParams: AgentRunParams
    deliberately dropped the id-only session_id in favour of session=, and
    a look-alike kwarg that only set a header would be a footgun (the existing
    TestAgentRunParamsKeys guard enforces this).

Adds unit coverage for header emission (each key alone and both together),
payload exclusion on the v2 + v1 builders, and the tool merge preserving
both run-metadata kwargs.

@elsheikhams99
elsheikhams99 requested a review from aix-ahmet July 29, 2026 13:57
@aix-ahmet
aix-ahmet merged commit 9acccf4 into development Jul 30, 2026
1 check passed
aix-ahmet added a commit that referenced this pull request Jul 31, 2026
Commit 9acccf4 (#1013) added session_id to Model._SDK_ONLY_PARAMS so it
never leaks into build_run_payload / build_run_url output, but the merge
of branch 'test' into development (dc8c4c2) resolved that hunk in favor
of the older frozenset, dropping the entry while keeping the feature's
tests and comments. Restore it to fix
test_session_id_excluded_from_build_run_payload on main and development.
aix-ahmet added a commit that referenced this pull request Jul 31, 2026
…1021)

Commit 9acccf4 (#1013) added session_id to Model._SDK_ONLY_PARAMS so it
never leaks into build_run_payload / build_run_url output, but the merge
of branch 'test' into development (dc8c4c2) resolved that hunk in favor
of the older frozenset, dropping the entry while keeping the feature's
tests and comments. Restore it to fix
test_session_id_excluded_from_build_run_payload on main and development.
hadi-aix pushed a commit that referenced this pull request Jul 31, 2026
…1020)

Commit 9acccf4 (#1013) added session_id to Model._SDK_ONLY_PARAMS so it
never leaks into build_run_payload / build_run_url output, but the merge
of branch 'test' into development (dc8c4c2) resolved that hunk in favor
of the older frozenset, dropping the entry while keeping the feature's
tests and comments. Restore it to fix
test_session_id_excluded_from_build_run_payload on main and development.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants