-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Studio: standalone Fetch pill for Anthropic web_fetch #5742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fa074e8
14142ee
9d2b0c2
523fac2
b20c41e
2872e39
0a3de26
ea98aeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -833,7 +833,13 @@ export function createOpenAIStreamAdapter(): ChatModelAdapter { | |
| // Re-read store after potential auto-load / model ready wait | ||
| runtime = useChatRuntimeStore.getState(); | ||
| const { params } = runtime; | ||
| const { supportsTools, toolsEnabled, codeToolsEnabled, imageToolsEnabled } = runtime; | ||
| const { | ||
| supportsTools, | ||
| toolsEnabled, | ||
| codeToolsEnabled, | ||
| imageToolsEnabled, | ||
| webFetchToolsEnabled, | ||
| } = runtime; | ||
| const externalSelection = parseExternalModelId(params.checkpoint); | ||
| const isExternalRequest = externalSelection !== null; | ||
| if ( | ||
|
|
@@ -889,14 +895,14 @@ export function createOpenAIStreamAdapter(): ChatModelAdapter { | |
| externalProvider.baseUrl, | ||
| ), | ||
| ); | ||
| // web_fetch shares the Search pill with web_search (no separate | ||
| // UI toggle), so it follows toolsEnabled. Anthropic is the only | ||
| // provider that ships it today; on others providerSupportsBuiltinWebFetch | ||
| // returns false and this stays inert. | ||
| // Fetch pill is independent of Search (Anthropic bills web_fetch | ||
| // separately from web_search). Sourced from `webFetchToolsEnabled`; | ||
| // on providers without web_fetch the toggle is forced off in | ||
| // chat-page's runtime setState. | ||
| const webFetchEnabledForThisTurn = | ||
| Boolean( | ||
| externalProvider && | ||
| toolsEnabled && | ||
| webFetchToolsEnabled && | ||
| providerSupportsBuiltinWebFetch(externalProvider.providerType), | ||
| ); | ||
|
Comment on lines
902
to
907
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for Currently, if a user enables the Fetch pill but leaves Search and Code disabled, the system prompt will incorrectly inform the model that it does not have access to web fetch capabilities. You should update the guard conditions to check |
||
| const providerShipsWebFetch = Boolean( | ||
|
|
@@ -941,14 +947,20 @@ export function createOpenAIStreamAdapter(): ChatModelAdapter { | |
| const webLabel = providerShipsWebFetch | ||
| ? "web search or web fetch" | ||
| : "web search"; | ||
| if (!webSearchEnabledForThisTurn && !codeExecEnabledForThisTurn) { | ||
| // Treat search and fetch as a single "any web tool" axis so | ||
| // the guard only warns when neither pill is on; checking | ||
| // webSearchEnabledForThisTurn alone mis-fired when only Fetch | ||
| // was on and suppressed live web_fetch calls. | ||
| const anyWebEnabledForThisTurn = | ||
| webSearchEnabledForThisTurn || webFetchEnabledForThisTurn; | ||
| if (!anyWebEnabledForThisTurn && !codeExecEnabledForThisTurn) { | ||
| disabledToolGuard = | ||
| `You do not have ${webLabel} or code execution tools in this conversation. ` + | ||
| "Answer from your own knowledge. " + | ||
| "If a request genuinely requires tool use, live data fetch or running code, " + | ||
| "inform the user that you do not have access to these capabilities. " + | ||
| "Do not return tool-call syntax inside your response."; | ||
| } else if (!webSearchEnabledForThisTurn) { | ||
| } else if (!anyWebEnabledForThisTurn) { | ||
| disabledToolGuard = | ||
| `You do not have ${webLabel} tools in this conversation. ` + | ||
| "You may still use code execution tools when they are available and useful. " + | ||
|
|
@@ -1419,13 +1431,8 @@ export function createOpenAIStreamAdapter(): ChatModelAdapter { | |
| enable_tools: true, | ||
| enabled_tools: [ | ||
| ...(webSearchEnabledForThisTurn ? ["web_search"] : []), | ||
| // Pair web_fetch with the Search pill on any | ||
| // provider that ships it (Anthropic today). The | ||
| // common workflow is "search returns URLs, fetch | ||
| // reads them"; without web_fetch the model can | ||
| // surface a citation but cannot quote from the | ||
| // page body, which is the whole point of the | ||
| // tool. There is no separate UI toggle yet. | ||
| // web_fetch has its own Fetch pill, independent | ||
| // of Search. Anthropic-only today. | ||
| ...(webFetchEnabledForThisTurn ? ["web_fetch"] : []), | ||
| ...(codeExecEnabledForThisTurn ? ["code_execution"] : []), | ||
| // OpenAI Responses-API only: `image_generation` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After introducing the standalone
webFetchToolsEnabledpath,createOpenAIStreamAdaptercomputeswebFetchEnabledForThisTurnbut thedisabledToolGuardbranching still only checkswebSearchEnabledForThisTurn/codeExecEnabledForThisTurn, so an Anthropic turn with Fetch ON and Search OFF is told “you do not have web search or web fetch tools.” In that state the model is instructed not to use a capability that is actually enabled, which can suppressweb_fetchtool calls and break the new standalone-fetch workflow.Useful? React with 👍 / 👎.