fix(aibridge): record all tool call types in responses interceptor - #24632
Closed
dannykopping wants to merge 1 commit into
Closed
fix(aibridge): record all tool call types in responses interceptor#24632dannykopping wants to merge 1 commit into
dannykopping wants to merge 1 commit into
Conversation
…onses interceptor Previously, the responses interceptor only recorded function_call and custom_tool_call types. This left tool calls like web_search_call, computer_call, shell_call, etc. unrecorded. Now all tool call types are recorded for auditor visibility. For new tool types, tool name falls back to the type field when no explicit name is set, and call ID falls back to id when call_id is empty. Adds ItemID field to ToolUsageRecord to capture the item-level identifier alongside the existing call-level ToolCallID. Ported from coder/aibridge#273
dannykopping
marked this pull request as ready for review
April 22, 2026 16:04
pawbana
approved these changes
Apr 23, 2026
| string(constant.ValueOf[constant.ShellCall]()), | ||
| string(constant.ValueOf[constant.ApplyPatchCall]()): | ||
| toolName = item.Name | ||
| if toolName == "" { |
Contributor
There was a problem hiding this comment.
nit: toolName is declared inside for loop so it is always empty?
|
|
||
| // Agentic tools: the client sends a corresponding *_output | ||
| // item correlated by call_id. | ||
| case "computer_call", |
Contributor
There was a problem hiding this comment.
very nit: could add comment about "computer_call" constant missing from SDK.
Maybe such constants could be extracted to some const package?
| Injected: false, | ||
| }); err != nil { | ||
| i.logger.Warn(ctx, "failed to record tool usage", slog.Error(err), slog.F("tool", item.Name)) | ||
| i.logger.Warn(ctx, "failed to record tool usage", slog.Error(err), slog.F("tool", toolName)) |
Contributor
There was a problem hiding this comment.
nit: maybe add "tool_call_id" and "item_id"to log?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: implemented by a Coder Agent using Claude Opus 4.6
Depends on #24562
Porting coder/aibridge#273 to coder/coder after the aibridge code move.
Summary
Previously, the responses interceptor only recorded
function_callandcustom_tool_calltypes. This left tool calls likeweb_search_call,computer_call,shell_call, etc. unrecorded, meaning interceptions that did significant work via built-in tools showed no tool usage at all.Now all tool call types are recorded for maximum auditor visibility:
function_callcustom_tool_callweb_search_callcomputer_calllocal_shell_callshell_callapply_patch_callcode_interpreter_callmcp_callfile_search_callimage_generation_callApproach
For the new tool types:
typefield when no explicitnameis set (most built-in tools don't have a name, unlike function calls).idwhencall_idis empty (web_search_call,file_search_call,code_interpreter_call,image_generation_calluseidinstead ofcall_id).message,reasoning,*_output, etc.) are still skipped.Changes
aibridge/intercept/responses/base.go: expandedrecordNonInjectedToolUsageswitch to handle all tool call types.aibridge/intercept/responses/base_test.go: addedweb_search_call_with_no_nameandall_additional_tool_typestest cases.aibridge/intercept/responses/injected_tools.go: addedItemIDto injected tool recording.aibridge/internal/integrationtest/responses_test.go: addedblocking_web_searchintegration test, updated existing tests withItemID.aibridge/fixtures/openai/responses/blocking/web_search.txtar: new fixture for a web search response.aibridge/fixtures/fixtures.go: embedded the new fixture.aibridge/recorder/types.go: addedItemIDfield toToolUsageRecord.