Repository navigation
fix(browsecomp): a provider content refusal fails one call, not the server - #6171
Conversation
…erver Exa answers some queries with HTTP 403 and "Sorry, we've detected unsafe content and can't ...". The harness treated every 401/403 as a rejected API key and called os._exit, so one refused query killed the search resources server. Every later search in the job then failed to connect and its rollouts timed out. A 403 whose body is a content-safety refusal now raises SearchProviderRefusal for that request, with no retry. The existing per-call handlers return "Search failed: ..." or "Failed to extract content: ..." to the agent, and the rollout continues and is graded normally. Every other 401/403 still aborts as a bad key. Co-authored-by: Jiaqi Zeng <[email protected]> Signed-off-by: Ananth Subramaniam <[email protected]>
|
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. |
The Tavily search helpers caught only BadRequestError, so a content refusal from Tavily escaped to the /search endpoint as a 500 instead of reaching the agent as a failed search. Both the inline and disk-mode helpers now return "Search failed: ..." for SearchProviderRefusal. Also correct the _abort_on_invalid_api_key docstring, which still said every 403 means a bad key. Signed-off-by: Ananth Subramaniam <[email protected]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE
RISK — Add the required real smoke-rollout evidence
The PR explicitly reports that no model smoke rollout ran. This changes environment behavior from terminating the resources server to returning a tool failure and continuing the rollout. Trusted AGENTS.md requires representative real smoke rollouts for behavior-changing environment work; mocked unit tests alone don't satisfy that requirement. Missing provider credentials explains the gap, but the complete agent → tools → final answer → verifier path remains unvalidated. This is a validation gap, not a demonstrated runtime defect.
Correction and acceptance: Could an author or maintainer with credentials run representative real model rollouts covering the affected Exa and Tavily configurations, including a per_session case for the changed disk helper? Record the head SHA, model, configs, commands, artifact locations, and inspected outcomes in the PR. The traces should show successful search/browse results reaching the model, continued agent execution, and completed verification without an unexpected tool exception or timeout. There's no need to force an unpredictable live refusal; keep deterministic tests for that branch. No source patch or reward-profile comparison is requested for this evidence gap.
Preservation checks: Retain the refusal and bad-key tests: a refusal must make one provider request without process exit and reach the agent as Search failed: ..., including both Tavily workspace modes; Exa 401 and non-refusal Tavily 403 must still exit with code 1. Normal search formatting, browse content, and clean disk-page writes must remain intact, as asserted by the provider success cases and disk-search coverage.
I found no additional qualifying code defect after inspecting both changed files and tracing the affected transport, batching, browse, metrics, agent-consumer, and verification paths. I couldn't execute tests or rollouts in this read-only review.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for this. One refused query taking down the search server for a whole job is a real problem, and this is a small, well-placed fix.
What the change does (as reviewed at 603ef8c0bb): a 403 whose body reads as a content-safety refusal now raises SearchProviderRefusal for that one request, with no retry. Every search and browse handler turns it into Search failed: <provider> refused this request: <body[:200]> or Failed to extract content: .... Other 401/403s still abort as a bad key.
What we checked and found fine:
- Scope: the refusal stays with one call. Each query in a
/searchbatch catches it in its own helper, browse catches it too, and later calls and the server process keep going. tavily-python 0.7.21 passes the exception through unchanged: it catches onlyhttpx.TimeoutExceptionaround the transportpost. - Classification: 403 is checked before
RETRY_ERROR_CODESand is in neither retry list, so a refusal is never retried or counted as a rate limit. 429/5xx handling is unchanged. - Reward: no reward or masking change. Scoring the rollout normally is right, because the model's own query caused the refusal and it can rephrase.
- Tests: the server suite passes at this head (271 tests). The new Tavily tests fail without the
app.pychange, including the disk-mode one.
The asks are inline:
- classify Exa refusals by their documented
tag; - a real-model run with an injected refusal, in place of the N/A;
- tighten the Exa end-to-end test;
- a refusal counter;
- two README sentences.
On the automated review: we agree real-model evidence is needed. A success-path run doesn't touch the 401/403 branch this PR changes, though, so the inline ask is for a run with an injected refusal instead.
Not part of this PR, possible follow-ups (all were here before):
- Exa 400/402 (for example
NO_MORE_CREDITS) come back from_postas data and are recorded as a successful empty search. - Tavily non-refusal errors (432/433
ForbiddenError, exhausted retries) still escape_search_one/_search_one_to_diskas a 500. TavilySearchAIOHTTPClientResponsehas noraise_for_status, so tavily-python's 422/434 branch raisesAttributeError.- The 401/403 body uses a strict
.decode().
Minor:
- Tavily documents no 403 content refusal, so the Tavily branch is defensive hardening; a word in the description would help.
- The PR has no labels yet.
This PR merges cleanly with #6088, which touches the same server, and refusals return before that PR's cache write, so a refusal is never cached.
| except SearchProviderRefusal as e: | ||
| self._record_call(metrics, "search", "tavily", "error", call_start) | ||
| print(f"[browsecomp][tool_fail][tavily_search] query={query[:200]!r} error={e}", flush=True) | ||
| return f"Search failed: {e}" |
There was a problem hiding this comment.
A refusal is recorded as "error", the same as a timeout or a bad request, and verify surfaces only num_provider_429s / num_provider_other_retries. A run where many queries are refused shows up only in the server log. Before this PR, the same condition crashed loudly. That includes a misclassified account-level 403 from the comment above. The metrics status is a free str (app.py:293), so could refused calls record "refused" here and in the Exa search and both browse handlers, with a num_provider_refusals count beside num_provider_429s? Small nit while here: each refusal is logged twice, [<provider>_refused] at app.py:483 plus the handler's own tool_fail line.
There was a problem hiding this comment.
Leaving this as a follow-up; it doesn't block the merge. In the smoke, refused calls showed up as search:error in session metrics, so a distinct status or counter would still help.
| """A 401, or a 403 that is not a content refusal, means the API key is bad: every search in | ||
| the run would silently degrade, so kill the benchmark instead of producing a garbage score.""" |
There was a problem hiding this comment.
The README's "Provider call limits" section (README.md:30-36) is where operators read how a provider call ends. It doesn't mention the bad-key abort or the new split. Could you add two sentences there: a 401, or a 403 that isn't a content refusal, stops the server; a content refusal fails only that call, as Search failed: ... or Failed to extract content: ...?
There was a problem hiding this comment.
Not blocking. These two README sentences can go in with the refusal-counter follow-up.
Exa marks every error body with a machine-readable tag. PROHIBITED_CONTENT and
CONTENT_FILTER_ERROR refuse one request; TEAM_BLOCKED and FEATURE_DISABLED reject
the account. Matching message text missed a CONTENT_FILTER_ERROR worded without
the listed phrases, which still aborted the server, and matched account-level
wording such as "content policy violation", which would have turned an account
rejection into a run of silently failed searches.
A 403 now counts as a refusal when its tag is one of the two per-request tags.
A body without a tag counts only with Exa's refusal wording ("unsafe content").
Tests cover both refusal tags, account-level tags that still abort, a 401 with
a refusal body, and an untagged policy-sounding 403. The Exa /search test now
drives the real client through a mocked 403.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: yaoyu-33 <[email protected]>
|
/ok to test dbd44dc |
yaoyu-33
left a comment
There was a problem hiding this comment.
Approving at dbd44dc.
What held from the first round: a provider refusal fails only its own call. Other queries in the batch, later calls and the server process keep working. A refusal is never retried or counted as a rate limit, and the rollout is scored normally, which is right because the model's own query caused it.
What dbd44dc changes: a 403 now counts as a refusal by Exa's documented tag (PROHIBITED_CONTENT or CONTENT_FILTER_ERROR). Account-level tags and any 401 still abort the run, and a body without a tag needs Exa's refusal wording. The Exa /search test now drives the real client.
Validation:
- The server suite passes (277 tests). The new tag tests fail on 603ef8c.
- Scoped pre-commit is clean.
- A real-model smoke with injected refusals covered Exa per_session, Tavily per_session and Tavily inline, 2 rows each. All 6 rollouts kept working after a refusal, reached a judged final answer unmasked, and the server never restarted. Details are in the reply on the rollout-evidence thread.
Not run:
- A live provider refusal; the bodies were injected.
- A live Exa key; Exa's other calls got canned results.
Left as follow-ups, not blocking:
- A
refusedstatus and counter in the metrics. - The two README sentences.
- The pre-existing Exa 400/402 and Tavily 432/433 handling listed in the first review.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/43569627383 |
What changed
The BrowseComp advanced harness treated every HTTP 401 or 403 from the search provider as a rejected API key and called
os._exit(1). Exa also answers some queries with a 403 whose body is a content-safety refusal ("Sorry, we've detected unsafe content and can't ..."). One refused query therefore killed the search resources server mid-training. Every later search in the job then failed to connect, and those rollouts timed out.This change separates the two cases in the Tavily and Exa clients:
unsafe content,content policy,content filterorcontent moderation) raisesSearchProviderRefusalfor that request, with no retry. The Exa search, Exa extract and Tavily extract handlers already turn exceptions intoSearch failed: ...orFailed to extract content: ...for the agent. The two Tavily search helpers (inline and disk mode) caught onlyBadRequestError, so they now also returnSearch failed: ...for a refusal. For both providers the rollout continues and is graded normally.Issue
No linked issue. Training recipes need a single provider refusal to fail one tool call, not take down the search server for the whole job.
Validation
The tests check that:
/search, reaches the agent as a failed search in both inline and disk mode, with one request and no process exit;Each new test fails on
mainwithout the change toapp.py. The disk-mode Tavily case also fails when only the disk-mode handler is removed.Commands run, from the repository root with a server venv built by
uv syncinresources_servers/browsecomp_advanced_harness:PYTHONPATH=$PWD resources_servers/browsecomp_advanced_harness/.venv/bin/python -m pytest resources_servers/browsecomp_advanced_harness/tests -q pre-commit run --files resources_servers/browsecomp_advanced_harness/app.py resources_servers/browsecomp_advanced_harness/tests/test_exa_provider.pyRollout evidence
N/A: no smoke rollout was run. The workstation has no Exa or Tavily API key and the shared vLLM server was down, so the author decided to skip the rollout. The refusal path cannot be triggered on demand against a live provider, so it is covered by unit tests that drive the real Tavily client through
/searchwith a mocked 403 refusal body, and that check the Exa client raises the refusal and that/searchreturns it to the agent as a failed search. The normal search path is unchanged.Compatibility
No config or API changes. Runs that previously crashed on a provider content refusal now continue, with that one tool call reported as failed.