feat: record and correlate tool call IDs across interceptions#188
Merged
dannykopping merged 9 commits intomainfrom Mar 2, 2026
Merged
feat: record and correlate tool call IDs across interceptions#188dannykopping merged 9 commits intomainfrom
dannykopping merged 9 commits intomainfrom
Conversation
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
pawbana
reviewed
Feb 24, 2026
cf82329 to
c91de99
Compare
Add CorrelatingToolCallID to the Interceptor interface, enabling interception lineage tracking. Each interceptor now scans backward through request messages/input to find the most recent tool call result, correctly identifying the parent interception that triggered the current one. Also record ToolCallID in non-injected tool usage for the responses API, which was previously missing and prevented lineage queries from finding parent interceptions. Changes: - Add CorrelatingToolCallID() to Interceptor interface - Add correlatingToolCallID field to all interceptor base types - Add backward scan loops in chatcompletions, messages, responses - Add scanForCorrelatingToolCallID() for responses API - Record ToolCallID in both injected and non-injected tool usage - Add CorrelatingToolCallID to InterceptionRecordEnded - Add ToolCallID to ToolUsageRecord - Pass CorrelatingToolCallID when ending interceptions in bridge.go - Update tests and integration test expectations Signed-off-by: Danny Kopping <danny@coder.com>
Extract scanForCorrelatingToolCallID() into methods on the base structs for chatcompletions and messages interceptors, matching the existing pattern in responses. Add TestScanForCorrelatingToolCallID table-driven tests for all three interceptors. Update MockRecorder to store full InterceptionRecordEnded structs instead of just timestamps, enabling richer test assertions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Danny Kopping <danny@coder.com>
The scan must happen once on the original request messages, not on every loop iteration. Inside the loop, appended injected tool results would be picked up instead of the original correlating tool call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
Move CorrelatingToolCallID from InterceptionRecordEnded to InterceptionRecord so that the parent correlation is passed at interception start time, when it is already known from the incoming request's input messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c91de99 to
1f6e9da
Compare
pawbana
approved these changes
Mar 2, 2026
Collaborator
Author
Merge activity
|
dannykopping
added a commit
to coder/coder
that referenced
this pull request
Mar 3, 2026
Adds database columns and server-side logic to track interception lineage via tool call IDs. When an interception ends, the server resolves the correlating tool call ID to find the parent interception and links them via `parent_id`. New `provider_tool_call_id` column on `aibridge_tool_usages` and `parent_id` column on `aibridge_interceptions`, with indexes for lookup. `findParentInterceptionID` queries by tool call ID and filters out the current interception to find the parent. Adapted from the [coder/coder `dk/prompt_provenance_poc`](main...dk/prompt_provenance_poc) branch. Depends on [coder/aibridge#188](coder/aibridge#188). Closes coder/internal#1334
pull bot
pushed a commit
to PterX/coder
that referenced
this pull request
Mar 3, 2026
) Adds database columns and server-side logic to track interception lineage via tool call IDs. When an interception ends, the server resolves the correlating tool call ID to find the parent interception and links them via `parent_id`. New `provider_tool_call_id` column on `aibridge_tool_usages` and `parent_id` column on `aibridge_interceptions`, with indexes for lookup. `findParentInterceptionID` queries by tool call ID and filters out the current interception to find the parent. Adapted from the [coder/coder `dk/prompt_provenance_poc`](coder/coder@main...dk/prompt_provenance_poc) branch. Depends on [coder/aibridge#188](coder/aibridge#188). Closes coder/internal#1334
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.

Track provider-supplied tool call IDs with each tool use response.
Add
CorrelatingToolCallIDto theInterceptorinterface for interception lineage tracking. Each interceptor scans backward through request messages to find the most recent tool call result, identifying the parent interception that triggered the current one.Adapted from the aibridge
prompt_provenance_pocbranch.Downstream: coder/coder#22246.
Closes #165