Repository navigation
feat(health): evaluate invocation-owned model calls - #2885
Conversation
|
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. |
|
🌿 Preview your docs: https://nvidia-preview-glovisotto-health-invocation-calls.docs.buildwithfern.com/nemo/gym Here are the markdown pages you've updated: |
d858c49 to
9a974a9
Compare
ad41700 to
ab7bde3
Compare
a636c29 to
382aad9
Compare
|
/claude review |
|
SHIP — LGTM, no reliability concerns. Reviewed the model-call binding refactor that splits the per-call
Tests assert real behavior; docs updated consistently. No async/public-API/dependency surface touched. |
|
is owned_model_calls interesting/enough evidence for us? I thought we seek full evidence only... |
382aad9 to
7ed32bb
Compare
Signed-off-by: Giulio Lovisotto <[email protected]>
Keep session association producer-owned and non-mutating. Index exact references so long rollouts remain linear, while missing or failed client correlation stays explicitly unowned. Signed-off-by: Giulio Lovisotto <[email protected]>
Pass an explicit title so OpenCode does not issue an auxiliary title-model request under the policy session. Clarify that ng_perf sums every invocation-owned call, including compaction when listed there. Signed-off-by: Giulio Lovisotto <[email protected]>
Signed-off-by: Giulio Lovisotto <[email protected]>
8799ef2 to
64f3136
Compare
Signed-off-by: Giulio Lovisotto <[email protected]>
Deduplicate after exact binding so equivalent references cannot double-count and stale turn references cannot hide invocation evidence. Preserve turn-bound aggregate semantics. Signed-off-by: Giulio Lovisotto <[email protected]>
Treat a missing saved response as unobserved when evaluating a length-limited call. Collapse indistinguishable reference mismatches without treating contradictory bindings as complete. Signed-off-by: Giulio Lovisotto <[email protected]>
ab7bde3 to
4917c1a
Compare
…2884) ## What does this PR do? Correlates OpenCode model requests with their exact `AgentInvocation` by retaining OpenCode's `X-Session-Id` request header as a single allowlisted capture field. During rollout finalization, calls whose client session matches an observed OpenCode invocation are projected as canonical `AgentInvocation.model_calls` references. This avoids timestamp, ordering, payload, and model-name inference. Calls with absent, conflicting, or unknown session ownership retain the existing `model_call_ownership_unavailable` gap. The session header is client-declared correlation evidence, not an authentication boundary. The standalone OpenCode harness supplies an explicit title so OpenCode does not make an auxiliary title-model request under the same session identity. Invocation-owned performance totals include every call listed by the harness, including compaction calls when they are also listed on the invocation. This PR is the producer half of a stack. Stacked draft #2885 lets call-level rollout-health checks consume exact invocation-owned calls when `TrajectoryTurn` placement is unavailable. ### Validation - `pytest tests/unit_tests/test_rollout_observability.py tests/unit_tests/test_base_responses_api_model.py tests/unit_tests/test_rollout_collection.py responses_api_agents/opencode_agent/tests/test_app.py -q` (336 passed) - OpenCode 1.17.11 local binary smoke against a localhost OpenAI-compatible endpoint: one `/v1/chat/completions` request; its `X-Session-Id` exactly matched the session persisted in OpenCode's SQLite database; no auxiliary title request - Producer association helper coverage: 100% (required: 96%) - `pre-commit run --all-files` ## Checklist - [x] I have read the [contributing guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format/copyright pass). - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Giulio Lovisotto <[email protected]>
The base branch was changed.
…2884) ## What does this PR do? Correlates OpenCode model requests with their exact `AgentInvocation` by retaining OpenCode's `X-Session-Id` request header as a single allowlisted capture field. During rollout finalization, calls whose client session matches an observed OpenCode invocation are projected as canonical `AgentInvocation.model_calls` references. This avoids timestamp, ordering, payload, and model-name inference. Calls with absent, conflicting, or unknown session ownership retain the existing `model_call_ownership_unavailable` gap. The session header is client-declared correlation evidence, not an authentication boundary. The standalone OpenCode harness supplies an explicit title so OpenCode does not make an auxiliary title-model request under the same session identity. Invocation-owned performance totals include every call listed by the harness, including compaction calls when they are also listed on the invocation. This PR is the producer half of a stack. Stacked draft #2885 lets call-level rollout-health checks consume exact invocation-owned calls when `TrajectoryTurn` placement is unavailable. ### Validation - `pytest tests/unit_tests/test_rollout_observability.py tests/unit_tests/test_base_responses_api_model.py tests/unit_tests/test_rollout_collection.py responses_api_agents/opencode_agent/tests/test_app.py -q` (336 passed) - OpenCode 1.17.11 local binary smoke against a localhost OpenAI-compatible endpoint: one `/v1/chat/completions` request; its `X-Session-Id` exactly matched the session persisted in OpenCode's SQLite database; no auxiliary title request - Producer association helper coverage: 100% (required: 96%) - `pre-commit run --all-files` ## Checklist - [x] I have read the [contributing guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format/copyright pass). - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Giulio Lovisotto <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
## What does this PR do? Extends five rollout-level checks to consume exact model-call references owned by either `TrajectoryTurn` or `AgentInvocation`: - `model_call_failed` - `model_call_missing_token_counts` - `model_call_runaway_generation` - `model_call_zero_completion_tokens` - `trajectory_capture_mismatch` The runner resolves exact references before deduplicating captured calls. Equivalent turn and invocation references therefore evaluate a call once, while an unbindable turn reference remains a correspondence finding without hiding a valid invocation reference. It never infers ownership from list position, timestamps, model names, or payload similarity. Repeated contradictory references for one call identity produce one mismatch finding without making the binding complete. Failed-call terminality follows the saved captured-call order. A length-limited call whose response payload was not retained makes `model_call_runaway_generation` unobserved instead of being treated as an empty response. Structural checks remain `TrajectoryTurn`-only. `rollout_token_count_mismatch` and `task_no_successful_model_calls` retain their existing turn-bound aggregate accounting. The rollout-health documentation states these evidence boundaries explicitly. This PR is stacked on and depends on #2884, which produces exact OpenCode `AgentInvocation.model_calls` ownership. ### Validation - `pytest tests/unit_tests/test_rollout_health.py -q` (64 passed) - Health and runner coverage: 98% (required: 96%) - Combined stack suite: 425 passed, 13 subtests passed - `pre-commit run --all-files` - `cd fern && npm run check` (0 errors) ## Checklist - [x] I have read the [contributing guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format/copyright pass). - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Giulio Lovisotto <[email protected]> Co-authored-by: ritaneves <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
## What does this PR do? Adds canonical `TrajectoryTurn` records to `opencode_agent` and `opencode_sandboxed_agent` when observability is enabled. This makes their persisted assistant content usable by `rollout_missing_agent_turns` and `agent_turn_hollow` health checks, while preserving the invocation-owned model calls introduced by NVIDIA-NeMo#2884 and consumed by NVIDIA-NeMo#2885. ### Evidence contract - A turn is one persisted OpenCode assistant message with provider-step evidence (`step-start` or `step-finish`). Its native message/part IDs establish membership; ordering only numbers turns within a session. - Answer text, reasoning, and tool calls come from that message's parts. Compaction summaries and explicitly synthetic shell/subtask bookkeeping do not become policy turns. - `question` stays unset: the persisted user message is not proof of the complete provider request. `step_count` counts completed provider steps cumulatively within each session. - `TrajectoryTurn.model_calls` stays empty. Existing exact `AgentInvocation.model_calls` ownership is preserved; this PR does not infer turn-to-call links from order, timing, or content similarity. - Interrupted, malformed, or incomplete evidence retains known content and records `turns_unavailable`, preventing content checks from declaring a partially observed trajectory healthy or hollow. There are no changes to health-check semantics, model servers, OpenCode itself, or existing configs. Call-level checks continue to consume invocation ownership; token-total reconciliation and the task-level successful-call check still require complete turn bindings. ### Validation - 184 agent, rollout-health, and observability regression tests passed; 190 rollout-collection tests passed. - New shared parser: 100% statement coverage. Existing application-module coverage is 93.07% (local) / 83.30% (sandboxed); this is not a claim of 100% coverage for those modules. - `pre-commit run --all-files` passed. - Real local OpenCode 1.17.11 run through Gym's model proxy: executed a Python calculation, wrote and verified `391`, produced three canonical turns and four invocation-owned captured calls. Content and owned-call checks evaluated with zero findings; overall verdict remained `unobserved` because token reconciliation lacks per-turn call references. - Both SQLite parsers produced identical canonical turns from the local live database. - Real Docker-backed OpenCode 1.17.11 smoke on ARM64: the sandboxed agent's `run()` path executed a Python calculation, wrote and independently verified `391`, exported its native SQLite evidence, and finalized with `opencode_finished=true`. It produced three canonical turns and three exactly invocation-owned captured calls. Independent checks confirmed native message/part membership and capture/session ownership. Health reports contained zero findings; content and owned-call checks evaluated, while overall verdict remained `unobserved` because token reconciliation lacks per-turn call references. - Docker smoke scope: a temporary driver supplied an already-created Docker sandbox because this branch's Docker provider lacks `serialize()/connect()` support. Sandbox reconnection was not exercised; agent execution, export, observation parsing, verification, and finalization used the real implementation. The small verifier checked the generated file, not a SWE-bench task. Existing sandbox-lifecycle timing and verifier-observation gaps remained. No repository files were changed for this smoke. The live run used a supported explicit OpenCode provider config. The automatic provider config reproduced an existing incompatibility: assistant tool-call history containing `reasoning: ""` is rejected by Gym's chat schema (HTTP 422). That separate issue is unchanged by this PR. ## Checklist - [x] I have read the [contributing guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format/copyright pass). - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Giulio Lovisotto <[email protected]>
Compaction summaries can contribute to response usage without becoming policy turns. The rollout token-total check previously summed only turn-bound calls and incorrectly reported those summaries as discrepancies. Compare response totals against the existing deduplicated invocation-or-turn-owned call view, which includes exactly owned compaction calls and still excludes unowned auxiliary calls. This intentionally advances only token-total accounting beyond the turn-only boundary retained in #2885. Successful-task-call checks and structural turn checks keep their existing scope. Missing or ambiguous references, missing token counts, and the existing incomplete-scope gap remain conservative; real total mismatches still produce findings. The documentation describes the revised contract. The change affects health accounting, not generated answers or benchmark rewards. Stacked on #3871, above #3856 / #3764 / #3711. This focused follow-up does not need a separate issue. Validation: - 96 focused tests pass: 71 health tests and 25 sandbox-agent tests. - New regressions cover invocation-only compaction accounting, duplicate references, unowned-call exclusion, missing captures and genuinely incorrect totals. The compaction regression fails against the parent implementation. - `pre-commit run --all-files` passes; Fern validation reports zero errors (authenticated redirect validation was skipped). - Ran the actual Gym health-check CLI at the prior tip `bbe2d7eb8d3d9bd702ae5f1416b1c6f335b9f550` over 2,193 retained records, saving new reports. On untouched records, all three compaction warnings clear. The broader ownership view also exposes 16 pre-existing unfinished-call usage discrepancies that turn-only accounting could not see. - A separately saved producer-usage replay for parent #3871 clears all 140 child-session mismatches. Final combined result: 2,175 healthy, 17 unhealthy, 1 unobserved; zero trajectory/capture mismatch findings and zero check execution errors. Remaining findings are the 16 unfinished native/captured-usage discrepancies and one recovered server-error incident; one sandbox failure lacks canonical evidence. - The child replay used retained native root exports plus capture-derived child token metadata passed through the production reader/converter: original child SQLite snapshots were unavailable. Original records/reports remain intact, no checks are ignored, and the parent PR separately has a live parent/child model smoke. This is not a new benchmark rollout or a score-parity claim. - Enabled GitHub checks pass at this head. Draft-gated automated review/integration checks were skipped; no unresolved review threads were present when checked. ## Parent header-property update Restacked on #3711, which now obtains the optional capture header from a harness-owned property. The previous run-level header option is removed. OpenCode declares its existing binary header in its own package; no binary rebuild or selection change is required. The focused property/startup/correlation suite passes 397 tests and all-files pre-commit passes. A fresh live attempt retained IDs but failed in the upstream proxy, so successful new deployment validation is not claimed. Historical deployment/replay results above remain tied to their original commits. The restacked accounting tip `a94028067d4861a14ccceb135e72fda0d554addd` passes **730 selected tests**, including both adapters, collection, shared correlation and health. No saved-run health replay was repeated for this wiring-only change. ## Rebase validation (2026-10-02) Rebased the five-PR stack onto `main` at `4f95540cc61c2ad783312d0cdb48d8a7c95c30e4`, preserving the new capture execution metadata and failed-call health checks. Each PR targets its immediate parent. At the final tip `00f19f01a18097cdbe7504de691090505effcbd9`: **918 selected tests pass**, all-files pre-commit passes, and Fern validation reports zero errors and one warning. Range-diff confirms only conflict-context adaptations; all nine commits retain DCO sign-off and SSH signatures. Historical deployment and saved-run replay results above remain tied to their original commits; no new model run or full saved-run health replay was performed for this rebase. Stack: main → #3711 → #3764 → #3856 → #3871 → #3872 --------- Signed-off-by: Giulio Lovisotto <[email protected]>
What does this PR do?
Extends five rollout-level checks to consume exact model-call references owned by either
TrajectoryTurnorAgentInvocation:model_call_failedmodel_call_missing_token_countsmodel_call_runaway_generationmodel_call_zero_completion_tokenstrajectory_capture_mismatchThe runner resolves exact references before deduplicating captured calls. Equivalent turn and invocation references therefore evaluate a call once, while an unbindable turn reference remains a correspondence finding without hiding a valid invocation reference. It never infers ownership from list position, timestamps, model names, or payload similarity. Repeated contradictory references for one call identity produce one mismatch finding without making the binding complete.
Failed-call terminality follows the saved captured-call order. A length-limited call whose response payload was not retained makes
model_call_runaway_generationunobserved instead of being treated as an empty response.Structural checks remain
TrajectoryTurn-only.rollout_token_count_mismatchandtask_no_successful_model_callsretain their existing turn-bound aggregate accounting. The rollout-health documentation states these evidence boundaries explicitly.This PR is stacked on and depends on #2884, which produces exact OpenCode
AgentInvocation.model_callsownership.Validation
pytest tests/unit_tests/test_rollout_health.py -q(64 passed)pre-commit run --all-filescd fern && npm run check(0 errors)Checklist
pre-commit run --all-files) (so CI lint/format/copyright pass).git commit -s) (so the DCO check passes).