Skip to content

fix(ai): isolate response tool call identities - #46084

Open
kitlangton wants to merge 5 commits into
v2from
responses-call-identity
Open

fix(ai): isolate response tool call identities#46084
kitlangton wants to merge 5 commits into
v2from
responses-call-identity

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Open Responses function calls have a stable external call_id, but optional item IDs and output indexes can be introduced, omitted, reused, or collide. Terminal reconciliation previously keyed pending accumulators through those aliases, which could drop authoritative completed arguments or apply a late event to another call.

What Changes

The parser now separates external identities from collision-free internal accumulator identities:

Identity Rule
call_id Stable emitted identity; first admission wins
output_index First-write-only routing identity for the response lifetime
Item ID Non-unique alias; item-only events fail when history is ambiguous
Internal key Unique accumulator identity, never exposed to consumers

Completed output-index mappings remain tombstones, and item aliases retain response-lifetime history. Late or ambiguous events therefore cannot be guessed onto a newer call. Done-only calls remain recoverable without contaminating the admitted-call maps.

Identity Invariants

  • Terminal arguments reconcile to the admitted call_id across item-ID introduction, omission, or change.
  • First-admission name and metadata remain authoritative.
  • Every admitted call completes at most once.
  • Concurrent or sequential alias reuse cannot overwrite another accumulator.
  • Valid official event sequences remain accepted; only genuinely ambiguous item-only argument events fail with their original event context.

Scope

This PR changes only Open Responses function-call accumulation and reconciliation. External event IDs and valid provider request/response shapes are unchanged.

Verification

cd packages/ai
bun run test
bun typecheck
git diff --check origin/v2...HEAD
  • 882 tests passed, 25 skipped, 0 failed.
  • Both AI typecheck configurations and workspace pre-push typechecks passed.
  • Independent final review pressure-tested collision/completion permutations, prototype-key IDs, ambiguity body retention, duplicates, late events, and done-only calls with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant