-
Notifications
You must be signed in to change notification settings - Fork 89
fix: add server_tool_use content blocks and tests for OpenAI native web search #26246
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
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 | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -298,8 +298,18 @@ export class OpenAIResponsesProvider implements Provider { | |||||||||||||||||||||||||||||||||||||||||||
| cleanupTimeout(); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Build content blocks | ||||||||||||||||||||||||||||||||||||||||||||
| // Build content blocks. | ||||||||||||||||||||||||||||||||||||||||||||
| // Inject server_tool_use blocks before text so conversation history | ||||||||||||||||||||||||||||||||||||||||||||
| // matches the shape Anthropic produces for native web search. | ||||||||||||||||||||||||||||||||||||||||||||
| const content: ContentBlock[] = []; | ||||||||||||||||||||||||||||||||||||||||||||
| for (const toolUseId of webSearchCallIds) { | ||||||||||||||||||||||||||||||||||||||||||||
| content.push({ | ||||||||||||||||||||||||||||||||||||||||||||
| type: "server_tool_use", | ||||||||||||||||||||||||||||||||||||||||||||
| id: toolUseId, | ||||||||||||||||||||||||||||||||||||||||||||
| name: "web_search", | ||||||||||||||||||||||||||||||||||||||||||||
| input: {}, | ||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+305
to
+312
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. 🔴 Missing The new code injects Expected fix patternAfter each for (const toolUseId of webSearchCallIds) {
content.push({
type: "server_tool_use",
id: toolUseId,
name: "web_search",
input: {},
});
content.push({
type: "web_search_tool_result",
tool_use_id: toolUseId,
content: [],
});
}
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||||||||||||||||||||||||||||
| if (contentText) { | ||||||||||||||||||||||||||||||||||||||||||||
| content.push({ type: "text", text: contentText }); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.
This now persists
server_tool_useblocks for OpenAI web-search calls but never emits a matchingweb_search_tool_resultblock, which means every such message is treated as orphaned server-tool output byrepairHistoryand gets a syntheticweb_search_tool_result_errorinjected on subsequent turns (via the pre-run repair path inconversation-agent-loop.ts). In practice, successful native web searches are rewritten as synthetic errors in runtime history, adding noisy repairs and polluting follow-up context; either emit a paired result block or avoid addingserver_tool_useuntil a pair can be represented.Useful? React with 👍 / 👎.