Skip to content

fix(agents): Antigravity's bridge binds a streamed call to a hooked call of its own trajectory - #970

Merged
earakely-scale merged 1 commit into
mainfrom
edgararakelyan/antigravity-result-binding
Nov 30, 2026
Merged

earakely-scale merged 1 commit into
mainfrom
edgararakelyan/antigravity-result-binding

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Antigravity's bridge could bind a tool's result to another trajectory's call: with a sub-agent beside the turn, when both had a call of one tool waiting for the hooks, each result could land on the other's call in the native log, and so in the atif/1 copy.

The bug

The SDK lets its hooks decide each call before it streams it. The hooks know a call by the model's id, the stream by a step's, so the bridge's TrajectoryRecorder ties them together: a streamed call took the first hooked call of its name not yet streamed, and a result that came before its call's stream waited for it. A hooked call kept no trajectory. When a sub-agent and the turn both had a call of one tool waiting, as run_command or view_file often are, and the sub-agent's streamed first, it took the turn's hooked call, and with it the turn's result if that had come first; the turn's call then took the sub-agent's. The adapter places each result on the call the bridge names, so the two traded places.

The fix

The SDK names a hooked call's step as it names its result's, from the trajectory and step index the harness gives (hook_router), and the recorded runs' results each name their own trajectory. So a hooked call now keeps the trajectory its step id names: a streamed call takes a hooked call of its own trajectory, and a result waits only for its own trajectory's. A hooked call that names no step binds as before.

Testing

  • Unit: a sub-agent's call of a tool the turn also has hooked, streamed first, with the turn's result already held: each result on its own call. It fails on main, where the two trade places. The test feed's hooked calls now name their step as the SDK's do. Antigravity's tests pass (357).
  • Chaos (kept outside the repo), the adapter chaos feat(agents): pydantic-ai, Letta Code, pi, Hermes, OpenHands, Antigravity, browser-use and OpenCode serve atif/1 #945 and fix(agents): Antigravity's atif/1 copy counts a turn's steps from where the task's first record puts them #968 used, its hooked calls now naming their step as the SDK's do, and holding every result to its own call unless two calls of one trajectory had a tool of one name waiting (it had excused any two trajectories, which hid this):
    • main's bridge fails 42 of the first 1,500 seeds, each a result on another trajectory's call.
    • This branch, 30 minutes on 5 workers of a test host: 914,509 seeds, 2 failures, each failing the same way on main and neither about binding (below).
    • With hooked calls that name no step (--hooks-unnamed): 183,241 seeds, 2 failures, main's binding failures, as this branch then binds as main does.
    • Every planted bug is caught, among them main's bridge (21 of 21).
  • Against main's bridge, every chaos seed through both, 30 minutes on a test host:
    • With hooked calls that name no step, as a harness that gave none: 78,686 seeds, the same native records on every one.
    • With them named: 78,772 seeds; 1,923 differ where main fails and this branch passes, 6 where both pass, none where this branch fails.
    • Every tool result against the call that truly made it, over 94,737 seeds: main puts 7,550 of 706,056 on another call and this branch 3,094; on the 2,337 seeds the two write differently, 4,684 of 35,747 against 228, this branch better on 2,306 and worse on none. What's left are cases the records leave ambiguous, which the chaos accepts, such as two calls of one trajectory with a tool of one name waiting at once.

Found, not fixed here

Two rare failures the long chaos reached (1 seed each in about 915,000), the same on main and neither about binding: a sub-agent's thought on the wrong call in a context's first task, and a refused call written as a model call.

🤖 Generated with Claude Code

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable issues were found.

Summary

The bridge now matches streamed tool calls to hooked calls from the same trajectory.

  • Antigravity keeps tool results with the call’s trajectory.

Acknowledged by earakely-scale: placing a sub-agent’s thought on the wrong call and recording a refused call as a model call are known, deferred issues. The PR description states that both also occur on main and are unrelated to this fix.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  H[Hooked call] --> T[Keep trajectory from step ID]
  S[Streamed call] --> M[Match tool name and trajectory]
  T --> M
  M --> B[Bind model ID to streamed ID]
  R[Early result] --> W[Wait for its trajectory's call]
  W --> B
  B --> N[Native result with call_ref]
  N --> A[ATIF result on the matching call]
Loading

Reviews (1) · Last reviewed commit: "fix(agents): Antigravity's bridge binds ..." · Reviewed by Greptile

…all of its own trajectory

The SDK lets its hooks decide a call before streaming it, and the bridge
bound each streamed call to the first undecided hooked call of its name.
With a sub-agent beside the turn, both may have one of a tool pending: when
the sub-agent's streamed first, it took the turn's hooked call, and with it
the turn's result if that had come first, so each result landed on the
other's call. A hooked call names its trajectory by its step id, as its
result does, so a streamed call now binds a hooked call of its own
trajectory, and a result waits only for its own trajectory's. A hooked call
that names no step binds as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 30, 2026 22:05
@earakely-scale
earakely-scale merged commit 6b416df into main Nov 30, 2026
35 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/antigravity-result-binding branch November 30, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant