Skip to content

feat(routing): opt-in X-Dynamo-Session-ID header from correlation ID#17

Open
ajcasagrande wants to merge 1 commit into
SemiAnalysisAI:cquil11/aiperf-agentx-v1.0from
ajcasagrande:ajc/agentx-dynamo-session-headers
Open

feat(routing): opt-in X-Dynamo-Session-ID header from correlation ID#17
ajcasagrande wants to merge 1 commit into
SemiAnalysisAI:cquil11/aiperf-agentx-v1.0from
ajcasagrande:ajc/agentx-dynamo-session-headers

Conversation

@ajcasagrande

Copy link
Copy Markdown

Summary

Bare-minimum enablement for Dynamo session-header affinity, following the existing env-toggle precedent already in base_transports (X-Session-ID, X-SMG-Routing-Key keyed off x_correlation_id). One new flag, one header block — no plugin machinery.

Set AIPERF_HTTP_X_DYNAMO_SESSION_ID_FROM_CORRELATION_ID=true and every request carries:

  • X-Dynamo-Session-ID = the stable x_correlation_id (same on every turn of a session)
  • X-Dynamo-Parent-Session-ID = the parent session's ID, only on subagent children

Pair with a Dynamo frontend running --router-session-affinity-ttl-secs to pin every turn of a session to the replica holding its KV prefix. Semantics match PR #15's dynamo_headers mode; this is the minimal header-only slice, not the full session_routing plugin layer.

Changes

  • environment.py — new X_DYNAMO_SESSION_ID_FROM_CORRELATION_ID bool (default False).
  • base_transports.py — emit the two headers in build_headers, parent only when parent_correlation_id is set.
  • test_base_transport.py — two tests mirroring the existing SMG/session-id toggle tests (root has no parent header; child adds it).
  • docs/environment-variables.md — regenerated.

Verification (over the wire)

Custom spawn dag_jsonl (root-A spawns child-A1/child-A2) run through aiperf profile against the in-repo mock server with --export-level raw. Raw-export request_headers is the exact dict handed to aiohttp session.post(headers=...); every request returned 200.

  • Flag ON: roots carry X-Dynamo-Session-ID (own corr) and no parent header; children carry both, with X-Dynamo-Parent-Session-ID equal to a real root correlation ID.
  • Flag OFF (control): zero X-Dynamo-* headers across all records.
  • Unit: tests/unit/transports/test_base_transport.py 29/29 pass.

🤖 Generated with Claude Code

Add AIPERF_HTTP_X_DYNAMO_SESSION_ID_FROM_CORRELATION_ID, following the
existing X-Session-ID / X-SMG-Routing-Key env-toggle precedent in
base_transports. When set, every request carries X-Dynamo-Session-ID
(the stable x_correlation_id), plus X-Dynamo-Parent-Session-ID on
subagent children, so a Dynamo frontend running
--router-session-affinity-ttl-secs pins every turn of a session to the
replica holding its KV prefix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Anthony Casagrande <acasagrande@nvidia.com>
@github-actions

Copy link
Copy Markdown

Try out this PR

Quick install:

pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@d14531b4a83e987c2477e82227ae2fd5184be755

Recommended with virtual environment (using uv):

uv venv --python 3.12 && source .venv/bin/activate
uv pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@d14531b4a83e987c2477e82227ae2fd5184be755

Last updated for commit: d14531bBrowse code

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