Repository navigation
fix(tau2): retry user-simulator and harness-data failures, and follow tau2 reruns - #4849
AdamRajfer wants to merge 5 commits into
Conversation
… tau2 reruns A malformed tool call from the user simulator's model was recorded as the policy's final `tau2_malformed_tool_call`. In evaluation it raises `Tau2UserSimulatorToolCallError` and is retried as `provider_unavailable`; with one shared server it stays the policy's. A missing Tau2 data or prompt file is retried too. A malformed tool call from the policy and an empty episode (`tau2_empty_output`) are the policy's failures that tau2 reruns: a new rule, retry then leave out, reruns them and leaves them out of the score at the attempt cap, in rollout collection and in `gym eval aggregate`. A context-window overflow (`tau2_context_overflow`) is left out. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
|
/ok to test 9ff2c25 |
|
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. |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — two BLOCKERs in evaluation failure classification and two RISKs remain.
Completed both review passes across all seven changed files and the directly affected retry, serialization, HTTP-error, and aggregation paths. Validation was static; no tests or model smoke rollouts were executed.
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.
| response = await self._run(body) | ||
| if is_eval_mode() and response.result.termination_reason == "empty_tool_calls_and_content": | ||
| # Evaluation reruns an empty episode, then leaves it out of the score at the attempt cap. | ||
| setattr(response, NG_FAILURE_CLASS_KEY, TAU2_EMPTY_OUTPUT_FAILURE_CLASS) |
There was a problem hiding this comment.
BLOCKER — The empty-episode marker is not serialized.
NG_FAILURE_CLASS_KEY starts with an underscore. Assigning that undeclared attribute with setattr() on a Pydantic model stores an ordinary private attribute, not an entry in its serialized extras. Consequently, a real Tau2VerifyResponse can expose the marker through getattr() while omitting it from /run JSON. The collector then persists the empty episode as a successful result rather than retrying it. The new test uses MagicMock and never checks serialization.
Correction: replace this assignment with an extra-aware copy:
response = response.model_copy(
update={NG_FAILURE_CLASS_KEY: TAU2_EMPTY_OUTPUT_FAILURE_CLASS}
)Tau2VerifyResponse inherits extra="allow", so model_copy(update=...) places the unknown key in serialized extras. Keep the condition evaluation-only and preserve every other response field.
Proposed acceptance checks: return a real response through /run, using the existing fake simulation with termination reason empty_tool_calls_and_content; assert the HTTP JSON contains _ng_failure_class="tau2_empty_output". Passing that JSON through collection must write a sidecar row, not a main-output row. Retain counting before the cap and exclusion at the cap. With evaluation disabled, the same episode must remain unchanged and unmarked; a normal user_stop episode must remain unmarked in both modes. Verify the suggested replacement before adoption.
There was a problem hiding this comment.
Fixed in 61ed2a1 (fix(tau2): serialize the empty-episode class so collection reruns it), with a test that fails without the fix.
| failure_class = TAU2_AGENT_FAILURE_CLASS | ||
| detail = _first_nested_exception(error) | ||
| return self._failure_response( | ||
| if eval_mode and _CONTEXT_OVERFLOW_PATTERN.search(f"{type(detail).__name__}: {detail}"): |
There was a problem hiding this comment.
BLOCKER — Context-overflow detection ignores the actual HTTP error body.
A normal model-server rejection reaches the adapter as aiohttp.ClientResponseError: for example, status 400, message Bad Request, and response_content=b'{"error":{"message":"maximum context length exceeded"}}'. Its string representation contains the status/reason/URL, not that payload. Gym's HTTP helper preserves the payload separately, and the Tau client uses that helper. This branch therefore misses the overflow and returns tau2_agent_error, which is counted as zero or retried instead of being unscored. The added test raises a fabricated RuntimeError whose message already includes the payload.
Correction: include the preserved payload in the classification text, for example at this location:
payload = getattr(detail, "response_content", "")
if isinstance(payload, bytes):
payload = payload.decode("utf-8", errors="replace")
if eval_mode and _CONTEXT_OVERFLOW_PATTERN.search(
f"{type(detail).__name__}: {detail} {payload}"
):
failure_class = TAU2_CONTEXT_OVERFLOW_FAILURE_CLASSPreserve ordinary non-overflow 4xx errors as model failures, non-overflow provider/transport failures as retryable, the existing user-simulator malformed-call override, and all non-evaluation classifications.
Proposed acceptance checks: inject an actual ClientResponseError with the overflow text only in response_content; cover both a propagated 400 and a proxy 500 carrying that body. Each evaluation response must be tau2_context_overflow, terminal and unscored. Non-overflow 400 must remain a counted model failure; non-overflow 429/503 must remain retryable; training must retain tau2_agent_error. Verify the suggestion against the model-server error path before adoption.
There was a problem hiding this comment.
Fixed in ee3257c (fix(tau2): read the HTTP error body when placing a context overflow), with a test that fails without the fix.
| this_task_transfer_to_human_agents = False | ||
| has_tool_call = False | ||
| for message in task["result"]["messages"]: | ||
| for message in result.get("messages") or []: |
There was a problem hiding this comment.
RISK — A resultless-only batch still crashes aggregation.
The new optional-result branch skips the message loop, but the final incomplete-reasoning metric still divides by total_num_assistant_messages. For compute_metrics([[{"config":{"domain":"retail"},"task":{"id":"x"},"reward":0.0}]]), that denominator is zero and the function raises ZeroDivisionError. This occurs when an evaluation batch contains only counted failures without results. The new regression test mixes its resultless row with healthy trajectories, so it keeps this denominator positive.
Correction: guard this diagnostic ratio, not the reward denominator:
"messages_with_incomplete_reasoning/pct": (
incomplete_reasoning / total_num_assistant_messages
if total_num_assistant_messages else 0.0
),Resultless failures must still contribute their zero reward, sample count, and no_result termination; they must not invent assistant messages or disappear from the score.
Proposed acceptance checks: the minimal batch above must return retail/reward=0.0, retail/num_samples_total=1, trajectory_termination_reason/no_result/count=1, and incomplete-reasoning percentage 0.0, without raising. Also exercise /aggregate_metrics with a real Tau2 failure response retaining its request fields. Preserve the mixed-batch no_result/count == 1 assertion and the existing healthy-fixture metrics, including its message finish-reason percentages. Verify the suggested guard before adoption.
| if not self.user_model_server_name or not self.policy_model_server_name: | ||
| return False | ||
| user_url = get_server_url(self.user_model_server_name) | ||
| return user_url != get_server_url(self.policy_model_server_name) and self.base_url.startswith(user_url) |
There was a problem hiding this comment.
RISK — URL-prefix matching can mistake the policy server for the simulator.
With user URL http://127.0.0.1:800 and policy URL http://127.0.0.1:8000, a policy client at http://127.0.0.1:8000/v1 passes startswith(user_url). A malformed policy call is consequently raised as Tau2UserSimulatorToolCallError and classified as provider_unavailable. Besides assigning the wrong cause, this retains the failed row in the denominator at the cap instead of applying the policy's retry-then-unscored rule.
Correction: require a URL boundary. The resolver returns a root URL without a trailing slash, and both inspected Tau2 callers append a slash-delimited path, so the smallest correction is:
return (
user_url != get_server_url(self.policy_model_server_name)
and self.base_url.startswith(user_url + "/")
)Retain the shared-server fallback and support both /v1 and rollout-prefixed simulator URLs.
Proposed acceptance checks: add the prefix-port pair above to the client test: policy /v1 and /ng-rollout/r/v1 URLs must return false; the corresponding user URLs must return true. With identical resolved roots, both must remain false. Inject malformed arguments through each client and assert the policy raises the base malformed-call error, while the distinct simulator raises the simulator subclass and receives the evaluation-only provider override. Verify the replacement before adoption.
There was a problem hiding this comment.
Fixed in cee28f4 (fix(tau2): tell the user simulator's server from the policy's at a path boundary), with a test that fails without the fix.
Bot finding 4339007810, PR NVIDIA-NeMo#4849 (part 7, Tau2). setattr of the underscore key _ng_failure_class on the pydantic response stored a private attribute, which /run never serialized, so an empty episode reached collection as a scored result instead of a rerun. model_copy(update=...) puts it in the serialized extras. Evaluation only, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Bot finding 4339007820, PR NVIDIA-NeMo#4849 (part 7, Tau2). A model server's 400 reaches the adapter as aiohttp's ClientResponseError, whose str() omits the body that says the context window overflowed; Gym keeps that body in response_content. The overflow check now reads it too, so the row is tau2_context_overflow (left out) instead of tau2_agent_error. Evaluation only, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Bot finding 4338966629, PR NVIDIA-NeMo#4844 (part 2, retry rule); the Tau2 metrics live in part 7. Final failures now reach /aggregate_metrics by default. A rollout without a result was already handled; a run with no assistant message at all still divided by zero in messages_with_incomplete_reasoning/pct. The denominator is at least 1, so that rate is 0 there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
…th boundary Bot finding 4339007849, PR NVIDIA-NeMo#4849 (part 7, Tau2). The check matched the user simulator's server URL as a plain string prefix, so a user server at :800 also matched a policy at :8000, and the policy's malformed tool call was retried as the user simulator's infra failure. The match now requires the path separator after the server root. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Adam Rajfer <[email protected]>
Part 7 of 9, merge in order. Stacked on #4848; the diff shows only this part's changes.
What and why. A malformed tool call from the user simulator's model was recorded as the policy's final
tau2_malformed_tool_call. In evaluation it raisesTau2UserSimulatorToolCallErrorand is retried asprovider_unavailable; with one shared server it stays the policy's. The user simulator's client is matched by its server URL at a path boundary, so a user server at:800does not claim a policy at:8000. A missing Tau2 data or prompt file is retried too. A malformed tool call from the policy and an empty episode (tau2_empty_output) are the policy's failures that tau2 reruns: a new rule, retry then leave out, reruns them and leaves them out of the score at the attempt cap, in rollout collection and ingym eval aggregate. A context-window overflow (tau2_context_overflow) is left out. It is found in the error text or in the model server's HTTP error body (response_content), which the error's string omits.Also: aggregation reads a rollout's result as optional, so a rollout counted as 0 without a result no longer crashes
compute_metrics; it counts undertrajectory_termination_reason/no_result. A run with no assistant message at all, where every rollout is a failure counted as 0, reportsmessages_with_incomplete_reasoning/pctas 0 instead of dividing by zero.Methodology. A failure the policy did not cause is retried, not scored. tau2 v1.0.1 reruns a failed simulation (
run_with_retry), records it as an infrastructure error once its retries are spent, and excludes those from its metrics; a context overflow is excluded too.Eval scores. Runs with user-simulator or harness-data failures move up once retries succeed. Runs with malformed or empty episodes that stay failing, or with context overflows, move up: those rows leave the denominator.
Training and RL: no change. The class and
failure_kindchange is behindis_eval_mode(); outside it the row keeps the class Tau2 always wrote, reward 0, and no kind. The new error is still aTau2MalformedToolCallError. The rule is evaluation scoring. Checked bytest_training_sees_the_failure_row_as_before.Unit tests.
responses_api_agents/tau2/tests/test_app.py, including aggregation with a zero-counted row that has no result;test_failure_retry_rule.py::TestTau2LeavesOutWhatItReruns(counted before the cap, left out at it, causemodel).🤖 Generated with Claude Code