feat(adaptive): add agent context propagation#281
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This would work for CLI-wrapped execution but wouldn't work in the general case (native OpenClaw plugin, DeepAgents integration, etc) In the ideal case this should be a universal request intercept which is registered. Principle of least astonishment would probably result in opt-in behavior through the This would bring it inline with the existing adaptive runtime behavior |
dbb7cea to
ea2f65a
Compare
Signed-off-by: Ishan Dhanani <ishandhanani@gmail.com>
ea2f65a to
0d8a5c5
Compare
Overview
Adds opt-in adaptive agent context propagation for coding-agent gateway traffic. Producers attach canonical context to scope metadata, and the adaptive
agent_contextrequest intercept copies the nearest active context into model requests at the configured body path (nvext.agent_contextby default).This keeps the feature general: Codex is only one producer used for validation, while the adaptive intercept is reusable by any coding-agent integration that records the same scope metadata.
Details
agent_contextconfiguration and a request intercept that resolves/nemo_relay/agent_contextfrom the nearest active scope, preserves caller-provided context, and no-ops when context or object request bodies are absent.Validation run:
cargo fmt --allgit diff --checkcargo test -p nemo-relay-clicargo test -p nemo-relay-adaptivejust test-rustPYO3_PYTHON=/ephemeral/NeMo-Relay/.venv/bin/python cargo clippy --workspace --all-targets -- -D warningscargo clippy -p nemo-relay-adaptive -p nemo-relay-cli --all-targets -- -D warningsuv run pytest python/tests/test_adaptive.py python/tests/test_adaptive_config.pyuv run ty check python/nemo_relay/adaptive.py python/nemo_relay/adaptive.pyijust test-pythonnemo-relay run --agent codexagainst Dynamo GLM-4.7-Flash TP2 with adaptiveagent_contextenabled. The fixed run produced 3 Dynamo request-trace rows withagent_context.session_type_id = "codex".Local toolchain blockers:
just test-nodefailed because local Node isv12.22.9; this repo requires Node 24 or newer.just test-gofailed becausegois not installed on PATH.just test-wasmfailed becausewasm-packis not installed on PATH.uv run pre-commit run --all-fileswas not rerun after this rework; the local Node/Go/WebAssembly blockers above would fail the relevant hooks.Live smoke artifacts:
/tmp/dyn-3207-codex-agent-context-fixed-request-trace.jsonl/tmp/dyn-3207-codex-agent-context-fixed-request-trace.perfetto.json/tmp/dyn-3207-codex-agent-context-fixed-last.txtWhere should the reviewer start?
Start with
crates/adaptive/src/agent_context_intercept.rsfor the generic request intercept, thencrates/cli/src/session.rsfor the Codex gateway producer path. The most useful tests arecrates/adaptive/tests/unit/agent_context_intercept_tests.rsandcrates/cli/tests/coverage/session_tests.rs.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)