Repository navigation
Studio: canonicalize and validate web_search arguments - #9716
Conversation
mahiatlinux
left a comment
There was a problem hiding this comment.
Fixed on 6b5c4b0. Malformed values no longer execute, URL-mode duplicates canonicalize correctly, and all three loop callers now assert canonical arguments.
mahiatlinux
left a comment
There was a problem hiding this comment.
Image-only mode is now documented and tested on 7f6df70.
|
@Souravrajvi0 I pushed two test commits here and rewrote the title and description. Revert any of it if you disagree. 0bc4141 clears the red 44fc8cc makes The description rewrite drops |
|
This PR is in good state, but it seems to solve an unobserved problem. #9709 concerns |
|
Confirmed the alias and non-string handling in studio/backend/core/inference/tools.py, and that prepare_call now canonicalizes before the duplicate key so |
Rebase onto current main. Heal q/search_query/href-style args local tool parsers emit before execute_tool, and canonicalize in prepare_call.
44fc8cc to
a4ee8a6
Compare
|
@danielhanchen — yes: we do not need a separate “frequency” study; the repo already encodes how often
|
| Arguments | main behavior |
This PR |
|---|---|---|
{"q": "unsloth"} |
No query provided. |
search runs |
{"href": "https://example.com"} |
No query provided. (no approval / no fetch) |
fetches page |
href / uri / link
We do not have a dedicated parser fixture that streams href instead of url (URL fetches are less common in the [ARGS]{...} templates). The PR adds test_web_search_heals_url_aliases for uri / href / link because HTML/API docs use those names and small models often mirror them — same motivation as q vs DuckDuckGo’s q parameter.
Scope vs #9709
Agreed this does not change the {} stall (#9709). This only fixes wrong-key but non-empty calls that parsers already deliver as q / href.
Branch
Rebased onto current main today (a4ee8a640) — should be mergeable again; focused 7-file diff unchanged.
… of the edit_file comment block
A 5-model A/B (greedy + sampled, 105 prompts per arm) showed the added sentences tie on Qwen3-8B, gemma-4-E4B and gpt-oss-20b, help Qwen3-4B, and regress Llama-3.2-3B URL fetches (30/30 -> 19/30 greedy), while empty calls were already ~1%. Argument healing stays in code.
|
Review record for #9716, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#323. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
Summary
Local models call
web_searchwith argument objects the tool cannot use, and onmainthose calls are quietly wasted:{"q": "unsloth"}(alsosearch_query,search,text) returnsNo query provided.without ever searching. OpenAI's hosted agent web tool takessearch_query/q, so OpenAI-trained models have seen that shape.{"href": "https://example.com"}(alsouri,link) never fetches the page. It does not prompt in "Approve for me" either, because_web_search_fetches_urlonly readsurl.{"query": 123}reaches.strip()in_web_searchand raises, which the loop reports back asError: tool raised an exception: 'int' object has no attribute 'strip'.What this PR does:
q,search_query,search,text) and the URL aliases (uri,href,link) to canonicalquery/url, and ignores non-string values instead of passing them down.ToolLoopController.prepare_call, so the status text, the auto-mode approval gate, the duplicate key and all three tool loops read the same arguments.{"href": "https://example.com"}now prompts in "Approve for me" and then fetches, where before it did neither.queryandimage_queriesfrom the duplicate key in URL mode, since_web_searchreturns from the URL branch before reading either, so those calls really are the same fetch.What this does not change
The tool description and schema the model sees are byte-identical to
main. An earlier revision added sentences naming the usable arguments; a 5-model A/B showed that was not a safe trade, so it was dropped:Greedy decoding, 50 search, 30 link-reading, 20 no-tool and 5 image prompts, with and without
image_queriesoffered; sampled runs (4 per prompt, temperature 0.7) agree. Empty calls were already rare onmain(at most 1 in 105 greedy calls per model).web_searchwith no usable arguments still returns exactlyNo query provided., whichTOOL_ERROR_PREFIXESalready classifies as a recoverable tool error. That is why this PR does not close #9709: for the{}call reported there,mainand this branch give the same result string,is_tool_error, duplicate key and model-visible message.Test plan
From
studio/backend:3075 passed. The new alias, URL-alias, non-string and duplicate-key tests fail on
mainand pass here; every test file that mentionsweb_search(86 files) has the same failure set onmainand on this branch.