Skip to content

feat(agent): carry trace context on the three remaining hand-off model URLs - #4927

Merged
iguehring-nvidia merged 1 commit into
mainfrom
iguehring/harness-urls-trace-context
Oct 26, 2026
Merged

iguehring-nvidia merged 1 commit into
mainfrom
iguehring/harness-urls-trace-context

Conversation

@iguehring-nvidia

@iguehring-nvidia iguehring-nvidia commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What changed and why

Follow-up to #4836 (merged), now on main. Three agents built the model URL they hand to a process outside Gym without base_url_for_run / resolve_model_base_url / apply_rollout_prefix, so after #4836 their harnesses' model calls still arrive at the model server with no traceparent and no URL-carried parent, and start their own traces.

  • harness_agent builds the sandbox model URL itself (loopback host rewritten, prefix from url_path_for_run("") kept in its run context). It now appends trace_context_path_segment() after that prefix, so the URL names the run's span while traces export.
  • harness_exa_search forwards the harness's model calls through an in-process relay that posts with a plain aiohttp session. The relay's upstream URL is now built per run by _upstream_model_url, which adds the segment after the rollout prefix. The explicit sandbox_model_base_url override keeps working.
  • cvdp_agent handed the sandbox a bare model URL in NV_MODEL_URL, with no rollout prefix either. It now goes through base_url_for_run, so it gets the rollout prefix (with capture on) and the trace segment (with traces on). Without either, the URL is unchanged.
  • Guard: a test in tests/unit_tests/telemetry/test_trace_context_path.py scans every responses_api_agents/*/app.py that exposes sandbox_model_base_url and requires one of the helpers (or opencode's inherited builder, which vibench uses). It fails for a new agent that hands a model URL to a sandbox by hand.

Agents checked and needing nothing: vibench (inherits opencode's builder, rewrites only the host), anyswe and anyterminal (direct helper calls, covered in #4836), simple_agent (Gym's own client), vcqa (external judge). harbor builds its own URL but for a Gym model server over Gym's client path and is out of scope here.

Compatibility

URLs change only while the process exports traces (segment) or capture is on (cvdp's new rollout prefix). No config change. No effect on benchmark results.

Validation

  • responses_api_agents/harness_agent/tests: segment after the run-context prefix, after the explicit override, and on the bare URL (59 passed with the guard and the feat(telemetry): carry trace context in the model URL for clients that send no traceparent #4836 module).
  • responses_api_agents/harness_exa_search/tests: _upstream_model_url with and without a prefixed request and with the override (module passes on its own; test_model_relay_round_trip is port-sensitive when run in one process with other agents' modules, as CI never does).
  • responses_api_agents/cvdp_agent/tests: NV_MODEL_URL carries the segment, and the rollout prefix with capture on (14 pass in the module).
  • tests/unit_tests/telemetry/test_trace_context_path.py: the new guard plus the feat(telemetry): carry trace context in the model URL for clients that send no traceparent #4836 suite. Running the cvdp module in the same pytest call as the others errored at collection locally; each module passes on its own.
  • pre-commit run on the changed files: clean.

Local before/after for harness_exa_search, no GPU

Real harness_exa_search agent with Gym's local sandbox provider, a harness in the sandboxed process that calls the model URL it was given with plain aiohttp (no traceparent), the real vllm_model server in front of a scripted stub, spans in memory, one /v1/responses call under a parent span (the gym-local-trace-check driver, --harness exa).

Gym model-server requests without parent parent in the parent's trace
main with #4836 (f36e1265, before this PR) 2 2 none 0
this PR bff18194 2 0 gym.agent.responses 2

harness_agent and cvdp_agent have no comparable local run: harness_agent installs Gym from a tarball inside the sandbox and runs a third-party CLI there, cvdp needs its hardware-design image under Apptainer. Their change is the same one-line URL construction, covered by unit tests.

Rollout evidence

N/A beyond the local exa run above: the mechanism (URL segment, server-side strip and parent) is the one verified in #4836 on tb4 (HSG job 8118123) and locally with pi and opencode.

@iguehring-nvidia iguehring-nvidia added feature New capabilities, enhancements, or enablement work area:agent Agent harnesses and Responses API agent behavior labels Oct 22, 2026
@iguehring-nvidia iguehring-nvidia self-assigned this Oct 22, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@iguehring-nvidia

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Oct 24, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP — LGTM — no reliability concerns.

Reviewed all seven changed files and traced the affected URL construction through the shared helpers, sandbox runners, relay, and receiving middleware. Rollout/token-capture prefixes remain before the trace segment, and tracing-disabled behavior is preserved.

Validation was limited to source and test inspection; tests were not executed in this read-only review.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Oct 26, 2026
…l URLs

Follow-up to #4836. harness_agent, harness_exa_search and cvdp_agent built
the model URL they give to a process outside Gym without the shared helpers,
so their harnesses' model calls still arrived with no parent.

harness_agent appends the current span's segment after the prefix it keeps
in its run context; harness_exa_search builds the relay's upstream URL per
run through a small method that adds it; cvdp_agent goes through
base_url_for_run, which also gives it the rollout prefix it never had. A
repo-wide test asserts that every agent exposing sandbox_model_base_url
builds its URL with the helpers, so the list cannot grow silently again.

Signed-off-by: Ingo Guehring <[email protected]>

@cmunley1 cmunley1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40412287857

Merged via the queue into main with commit 45ceac0 Oct 26, 2026
54 of 57 checks passed
@iguehring-nvidia
iguehring-nvidia deleted the iguehring/harness-urls-trace-context branch October 26, 2026 22:56

This branch was previously deployed

1 inactive deployment
public — f8273858 Deployed Oct 26, 2026 by copy-pr-bot[bot] via release / finalize / notify #7422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants