Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(aibridge): record all tool call types in responses interceptor - #24632

Closed
dannykopping wants to merge 1 commit into
mainfrom
fix/record-all-tool-types
Closed

fix(aibridge): record all tool call types in responses interceptor#24632
dannykopping wants to merge 1 commit into
mainfrom
fix/record-all-tool-types

Conversation

@dannykopping

@dannykopping dannykopping commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

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_call and custom_tool_call types. This left tool calls like web_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:

Tool type Previously recorded Now recorded
function_call Yes Yes
custom_tool_call Yes Yes
web_search_call No Yes
computer_call No Yes
local_shell_call No Yes
shell_call No Yes
apply_patch_call No Yes
code_interpreter_call No Yes
mcp_call No Yes
file_search_call No Yes
image_generation_call No Yes

Approach

For the new tool types:

  • Tool name falls back to the type field when no explicit name is set (most built-in tools don't have a name, unlike function calls).
  • Call ID falls back to id when call_id is empty (web_search_call, file_search_call, code_interpreter_call, image_generation_call use id instead of call_id).
  • Non-tool output types (message, reasoning, *_output, etc.) are still skipped.

Changes

  • aibridge/intercept/responses/base.go: expanded recordNonInjectedToolUsage switch to handle all tool call types.
  • aibridge/intercept/responses/base_test.go: added web_search_call_with_no_name and all_additional_tool_types test cases.
  • aibridge/intercept/responses/injected_tools.go: added ItemID to injected tool recording.
  • aibridge/internal/integrationtest/responses_test.go: added blocking_web_search integration test, updated existing tests with ItemID.
  • 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: added ItemID field to ToolUsageRecord.

…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 dannykopping changed the title fix(aibridge/intercept/responses): record all tool call types in responses interceptor enhancement: record all tool call types in responses interceptor Apr 22, 2026
@dannykopping
dannykopping marked this pull request as ready for review April 22, 2026 16:04
@dannykopping
dannykopping requested a review from pawbana April 22, 2026 16:04
@dannykopping dannykopping changed the title enhancement: record all tool call types in responses interceptor fix(aibridge): record all tool call types in responses interceptor Apr 23, 2026
string(constant.ValueOf[constant.ShellCall]()),
string(constant.ValueOf[constant.ApplyPatchCall]()):
toolName = item.Name
if toolName == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe add "tool_call_id" and "item_id"to log?

@github-actions github-actions Bot added the stale This issue is like stale bread. label May 7, 2026
@github-actions github-actions Bot closed this May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants