Skip to content

feat(observability): agent-side url_path/base-URL helpers + wire remaining url_path-style agents - #1994

Merged
Glorf merged 1 commit into
feat/model-server-observabilityfrom
ffrujeri/feat/model-server-observability
Jul 11, 2026
Merged

Glorf merged 1 commit into
feat/model-server-observabilityfrom
ffrujeri/feat/model-server-observability

Conversation

@ffrujeri

Copy link
Copy Markdown
Contributor

Summary

Gives every agent a one-call way to correlate its model calls with a rollout for model-call capture, and wires the remaining url_path-style agent harnesses with it. Also addresses the PR #1715 review ask to collapse apply_rollout_prefix(base_url, self.rollout_id_from_run(body)) into a single function.

Correlation is now gated on observability_enabled: when capture is off, no agent emits /ng-rollout/<id> prefixes anywhere — URLs stay clean instead of carrying a prefix the model server strips and ignores.

New helpers on SimpleResponsesAPIAgent

  • url_path_for_run(url_path, body) — returns /ng-rollout/<id><url_path> when observability is enabled and the run body carries task/rollout indices; otherwise url_path unchanged. Used for downstream calls made while handling /run (direct model calls or self-calls to /v1/responses).
  • base_url_for_run(base_url, body) — the base-URL counterpart with identical gating, for SDK-style harnesses that configure a client once instead of prefixing each call. This is the one-function collapse requested in the feat(observability): add per-rollout model-call capture #1715 review.
  • url_path_for_request(url_path, request) — for agents whose model calls happen inside responses(): carries an inbound prefixed self-call's rollout id (from the request's path params) onto the outgoing model call.
  • rollout_id_from_run(body) now applies the observability gate itself (fail-closed: no usable global config → uncorrelated, never an error). This is the single gate point, so the base-URL agents already wired on the parent branch (claude_code, anyterminal, mini_swe_agent_2) became gated with no changes to their code. It remains public because some flows need the bare id: claude_code and anyterminal thread it through layers that have no run body, and hermes' responses() derives it from path params.
  • The prefixed self-call route /ng-rollout/{rollout_id}/v1/responses is registered on every agent by the base setup_webserver(), so agents no longer hand-register it (hermes' override removed).

Agents wired

Model calls in these harnesses are now correlated (and therefore captured when observability is on):

  • New: simple_agent, non_executing_simple_agent, tool_simulation_agent (its responses() gained a Request parameter), proof_refinement_agent, critpt_agent, cvdp_agent, speed_bench_agent, browsecomp_agent, and aviary_agent (its responses() receives the full run request in-process, so it uses url_path_for_run directly on the model call).
  • Refactored to the helpers: hermes_agent and gymnasium_agent (previously hand-rolled rollout_path_prefix f-strings, applied unconditionally — they now gate on observability like everyone else), and mini_swe_agent_2 (the feat(observability): add per-rollout model-call capture #1715-flagged line is now self.base_url_for_run(base_url, body)).

The wiring pattern for the common shape (model calls inside responses(), run() self-calls /v1/responses): run() prefixes the self-call via url_path_for_run, the base-registered prefixed route carries the id in, and responses() re-applies it to the model call via url_path_for_request.

Not wired here (bespoke model plumbing, each needs individual treatment): harbor_agent, finance_agent, langgraph_agent, tau2, scicode_agent, stirrup_agent, verifiers_agent, swe_agents, mini_swe_agent.

Behavior change

Hermes and gymnasium previously applied the correlation prefix unconditionally. Harmless in practice (the model-server middleware strips it either way), but now the prefix appears only when observability_enabled: true, consistent across all harness styles.

Testing

  • New unit tests for the helpers: gate on/off, missing indices, fail-closed on unusable config, inbound-prefix propagation (including non-Starlette request objects), and default prefixed-route registration.
  • gym dev test: 1178 passed, 97.27% coverage (gate ≥96%); the only 2 failures are the pre-existing test_opensandbox_provider.py ones.
  • All touched agent suites pass: simple (6), non_executing_simple (4), tool_simulation (2), proof_refinement (2), critpt (15), cvdp (3), aviary (7), gymnasium (8, incl. a new gate-off test), mini_swe_agent_2 (22), claude_code (43), anyterminal (66).
  • Pre-existing failures verified unrelated by stashing: browsecomp's 3 responses() tests (Hydra parsing in app.py:197) and speed_bench's collection error (needs its per-server venv). hermes' suite requires model_tools locally; its correlation test exercises the responses-side path, which is behaviorally unchanged.
  • Docs: the correlation section of model-call-capture.mdx documents the helpers and the gating.

@copy-pr-bot

copy-pr-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ffrujeri
ffrujeri changed the base branch from main to feat/model-server-observability July 10, 2026 19:00
@github-actions

Copy link
Copy Markdown
Contributor

@ffrujeri ffrujeri mentioned this pull request Jul 10, 2026
10 tasks
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Michal Bien <[email protected]>
@Glorf
Glorf force-pushed the ffrujeri/feat/model-server-observability branch from 05ba504 to 45647da Compare July 11, 2026 13:08
@Glorf
Glorf merged commit 52dfd5a into feat/model-server-observability Jul 11, 2026
16 checks passed
@Glorf
Glorf deleted the ffrujeri/feat/model-server-observability branch July 11, 2026 13:08
Glorf pushed a commit that referenced this pull request Jul 14, 2026
…ining url_path-style agents (#1994)

Gives every agent a one-call way to correlate its model calls with a
rollout for model-call capture, and wires the remaining url_path-style
agent harnesses with it. Also addresses the PR #1715 review ask to
collapse `apply_rollout_prefix(base_url,
self.rollout_id_from_run(body))` into a single function.

Correlation is now gated on `observability_enabled`: when capture is
off, no agent emits `/ng-rollout/<id>` prefixes anywhere — URLs stay
clean instead of carrying a prefix the model server strips and ignores.

- **`url_path_for_run(url_path, body)`** — returns
`/ng-rollout/<id><url_path>` when observability is enabled and the run
body carries task/rollout indices; otherwise `url_path` unchanged. Used
for downstream calls made while handling `/run` (direct model calls or
self-calls to `/v1/responses`).
- **`base_url_for_run(base_url, body)`** — the base-URL counterpart with
identical gating, for SDK-style harnesses that configure a client once
instead of prefixing each call. This is the one-function collapse
requested in the #1715 review.
- **`url_path_for_request(url_path, request)`** — for agents whose model
calls happen inside `responses()`: carries an inbound prefixed
self-call's rollout id (from the request's path params) onto the
outgoing model call.
- **`rollout_id_from_run(body)`** now applies the observability gate
itself (fail-closed: no usable global config → uncorrelated, never an
error). This is the single gate point, so the base-URL agents already
wired on the parent branch (claude_code, anyterminal, mini_swe_agent_2)
became gated with no changes to their code. It remains public because
some flows need the bare id: claude_code and anyterminal thread it
through layers that have no run body, and hermes' `responses()` derives
it from path params.
- The prefixed self-call route `/ng-rollout/{rollout_id}/v1/responses`
is registered on every agent by the base `setup_webserver()`, so agents
no longer hand-register it (hermes' override removed).

Model calls in these harnesses are now correlated (and therefore
captured when observability is on):

- **New:** `simple_agent`, `non_executing_simple_agent`,
`tool_simulation_agent` (its `responses()` gained a `Request`
parameter), `proof_refinement_agent`, `critpt_agent`, `cvdp_agent`,
`speed_bench_agent`, `browsecomp_agent`, and `aviary_agent` (its
`responses()` receives the full run request in-process, so it uses
`url_path_for_run` directly on the model call).
- **Refactored to the helpers:** `hermes_agent` and `gymnasium_agent`
(previously hand-rolled `rollout_path_prefix` f-strings, applied
unconditionally — they now gate on observability like everyone else),
and `mini_swe_agent_2` (the #1715-flagged line is now
`self.base_url_for_run(base_url, body)`).

The wiring pattern for the common shape (model calls inside
`responses()`, `run()` self-calls `/v1/responses`): `run()` prefixes the
self-call via `url_path_for_run`, the base-registered prefixed route
carries the id in, and `responses()` re-applies it to the model call via
`url_path_for_request`.

Not wired here (bespoke model plumbing, each needs individual
treatment): `harbor_agent`, `finance_agent`, `langgraph_agent`, `tau2`,
`scicode_agent`, `stirrup_agent`, `verifiers_agent`, `swe_agents`,
`mini_swe_agent`.

Hermes and gymnasium previously applied the correlation prefix
unconditionally. Harmless in practice (the model-server middleware
strips it either way), but now the prefix appears only when
`observability_enabled: true`, consistent across all harness styles.

- New unit tests for the helpers: gate on/off, missing indices,
fail-closed on unusable config, inbound-prefix propagation (including
non-Starlette request objects), and default prefixed-route registration.
- `gym dev test`: 1178 passed, 97.27% coverage (gate ≥96%); the only 2
failures are the pre-existing `test_opensandbox_provider.py` ones.
- All touched agent suites pass: simple (6), non_executing_simple (4),
tool_simulation (2), proof_refinement (2), critpt (15), cvdp (3), aviary
(7), gymnasium (8, incl. a new gate-off test), mini_swe_agent_2 (22),
claude_code (43), anyterminal (66).
- Pre-existing failures verified unrelated by stashing: browsecomp's 3
`responses()` tests (Hydra parsing in `app.py:197`) and speed_bench's
collection error (needs its per-server venv). hermes' suite requires
`model_tools` locally; its correlation test exercises the responses-side
path, which is behaviorally unchanged.
- Docs: the correlation section of `model-call-capture.mdx` documents
the helpers and the gating.

Signed-off-by: Felipe Vieira Frujeri <[email protected]>
Signed-off-by: Michal Bien <[email protected]>
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