Skip to content

fix(worker): add Dynamo session control for replay sessions#5

Open
weireweire wants to merge 2 commits into
SemiAnalysisAI:cjq/agentx-v0.3from
weireweire:dynamo-session-control-aiperf-semianalysis
Open

fix(worker): add Dynamo session control for replay sessions#5
weireweire wants to merge 2 commits into
SemiAnalysisAI:cjq/agentx-v0.3from
weireweire:dynamo-session-control-aiperf-semianalysis

Conversation

@weireweire

@weireweire weireweire commented Jun 11, 2026

Copy link
Copy Markdown

Summary

  • add opt-in Dynamo conversation-aware routing metadata via nvext.session_control
  • use each request credit's X-Correlation-ID as nvext.session_control.session_id
  • fix session bind lifecycle handling for warmup, profiling continuation, recycled sessions, and branch orchestration
  • add debug sampling fields for Dynamo session/request inspection
  • fix FIRST_TURN cache-bust marker injection for mid-turn agentic replay resumes by marking seeded turn 0 history exactly once

Validation

  • PYTHONPATH=tests uv run --with pytest-asyncio pytest tests/unit/common/config/test_endpoint_config.py tests/unit/common/models/test_endpoint_info.py tests/unit/credit/test_issuer.py tests/unit/credit/test_structs.py tests/unit/timing/strategies/test_agentic_replay.py tests/unit/timing/test_branch_orchestrator_pre_session.py tests/unit/workers/test_worker.py tests/unit/workers/test_worker_cache_bust_injection.py tests/unit/workers/test_worker_cache_bust_adversarial.py -q (186 passed)
  • uv run --with 'ruff>=0.14.0,<0.15.0' ruff check src/aiperf/workers/worker.py tests/unit/workers/test_worker.py\n

Note

Medium Risk
When routing is enabled, every outbound request body gains merged nvext metadata; cache-bust semantics changed for FIRST_TURN and repeated injection, which can alter KV-cache behavior in benchmarks.

Overview
Adds opt-in Dynamo conversation-aware routing via endpoint flags that emit nvext.session_control on OpenAI-compatible request bodies, with configurable session timeout (default 300s). Config flows from CLI/EndpointConfig into runtime EndpointInfo.

When enabled, the worker merges session_control into the last turn’s extra_body, raw_payload, or decoded payload_bytes, using credit.x_correlation_id as session_id and sending action: bind only on the first request per worker for that session (tracked in _dynamo_bound_session_ids).

Cache-bust fixes: marker injection is idempotent (skips if content already contains the marker), and FIRST_TURN_* targets apply to the seeded first user turn even when credits resume at turn_index > 0 (agentic replay), without duplicating markers on repeated _apply_cache_bust calls.

Reviewed by Cursor Bugbot for commit 8c9067d. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown

Try out this PR

Quick install:

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

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@8c9067d0bd8d13161606b2ab59307f896b82ae99

Last updated for commit: 8c9067dBrowse code

@weireweire weireweire changed the title fix(worker): add first-turn marker to seeded replay history fix(worker): add Dynamo session control for replay sessions Jun 11, 2026
@functionstackx functionstackx requested a review from cquil11 June 11, 2026 04:53
@weireweire weireweire force-pushed the dynamo-session-control-aiperf-semianalysis branch from ae553d4 to 6d62c91 Compare June 11, 2026 05:09
Comment thread src/aiperf/timing/strategies/agentic_replay.py Outdated
Comment thread src/aiperf/timing/strategies/agentic_replay.py Outdated
@weireweire weireweire force-pushed the dynamo-session-control-aiperf-semianalysis branch from 6d62c91 to 948925a Compare June 11, 2026 05:27

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 948925a. Configure here.

Comment thread src/aiperf/timing/branch_orchestrator.py Outdated
Comment thread src/aiperf/workers/worker.py Outdated
@weireweire weireweire force-pushed the dynamo-session-control-aiperf-semianalysis branch 3 times, most recently from d47d1a9 to 4bf761e Compare June 11, 2026 06:38
@weireweire weireweire force-pushed the dynamo-session-control-aiperf-semianalysis branch from 4bf761e to 8c9067d Compare June 11, 2026 06:46
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.

1 participant