feat: record all tool call types - #26855
Merged
Merged
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
dannykopping
force-pushed
the
dk/record-all-tool-types
branch
2 times, most recently
from
June 30, 2026 12:12
f2e690f to
a876e19
Compare
dannykopping
marked this pull request as ready for review
June 30, 2026 12:16
pawbana
approved these changes
Jul 2, 2026
Previously the responses interceptor only recorded function_call and custom_tool_call output items, so interceptions that did real work via built-in tools (web_search_call, computer_call, shell_call, mcp_call, etc.) showed no tool usage at all. recordNonInjectedToolUsage now whitelists every tool-call output type and records it. The tool name falls back to the item type when no explicit name is set (built-in tools usually have none). ToolUsageRecord gains a separate ItemID field so the two distinct Responses identifiers are captured without conflation: - ItemID: the output item's unique id (always present). - ToolCallID: the call_id correlation id (empty for hosted tools the provider executes internally).
Adds blocking and streaming web_search.txtar fixtures (derived from a real gpt-5.4 Responses payload, scrubbed of credentials and identifying metadata) and TestResponsesOutputMatchesUpstream cases for both paths. Each case validates a hosted tool call: web_search_call is recorded, its ToolCallID is empty (the provider runs it server-side, so there is no call_id), and ItemID captures the output item's id.
dannykopping
force-pushed
the
dk/record-all-tool-types
branch
from
July 6, 2026 06:55
a876e19 to
3c594fa
Compare
Contributor
Author
Merge activity
|
dannykopping
added a commit
that referenced
this pull request
Jul 6, 2026
## Summary Plumbs the Responses output item id (added as `ToolUsageRecord.ItemID` in #26855) through to the database, captured independently of the `provider_tool_call_id` correlation key. Hosted tools (`web_search_call`, etc.) only have an item id; agentic tools have both. `provider_item_id` is specific to the OpenAI Responses API; it stays empty for chat completions and Anthropic messages, which have no separate item id. ## Changes - Migration `000534`: nullable `provider_item_id` column on `aibridge_tool_usages`. - Proto: `item_id` field 11 on `RecordToolUsageRequest`. - Server handler: persists `provider_item_id` and adds it to structured logging. - Translator: maps `ToolUsageRecord.ItemID` to the proto field. ## Tests - `TestRecordToolUsageProviderItemID`: real-database round-trip asserting `provider_item_id` persists for both hosted and agentic tools, independently of `provider_tool_call_id`. Stacked on #26855. Linear: AIGOV-96 --- _This PR was produced by opencode (agent) using the_ _`anthropic/claude-opus-4-8`_ _model, under human direction and review._
jaaydenh
added a commit
that referenced
this pull request
Jul 7, 2026
Resolve conflicts from main: - Drop UpdateChatStatusPreserveUpdatedAt (query, dbauthz wrapper, and its generated code): main removed it in #26980 (remove chat chain mode). Keep the branch's UpdateChatSummary. - Renumber chat_summary migration 000538 -> 000540 to avoid colliding with main's new 000538_chat_shared_notification and 000539_ai_provider_icons. Verified the chats_expanded recreation matches main's latest view plus the two summary columns (up), and the down migration restores main's view. - querier_test.go: drop ProviderResponseID from InsertChatMessagesParams in TestUpdateChatSummary; main's #26855/#26856 refactor removed that field. - Regenerated queries.sql.go/querier.go/dbmock/querymetrics/audit-logs/apidoc/ types from the merged sources (picks up main's ai_providers Icon, etc.).
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.

Summary
The Responses interceptor previously recorded only
function_callandcustom_tool_calloutput items, so interceptions that did real work via built-in tools (web_search_call,computer_call,shell_call,mcp_call, etc.) recorded no tool usage at all.recordNonInjectedToolUsagenow whitelists every tool-call output type and records it, with the tool name falling back to the item type when none is set.ToolUsageRecordalso gains anItemIDfield so the two distinct Responses identifiers are captured without conflation (addresses review feedback on coder/aibridge#273):ItemID: the output item's uniqueid(always present).ToolCallID: thecall_idcorrelation id (empty for hosted tools the provider runs server-side).Tests
TestRecordToolUsagewith cases for the new hosted/agentic tool types.web_searchfixtures (scrubbed of credentials and identifying metadata) plusTestResponsesOutputMatchesUpstreamcases asserting a hosted tool records with an emptyToolCallIDand a populatedItemID.Linear: AIGOV-96
This PR was produced by opencode (agent) using the
anthropic/claude-opus-4-8model, under human direction and review.