Skip to content

fix(pi): preserve Antigravity state across turns - #7

Merged
ualtinok merged 3 commits into
cortexkit:mainfrom
asp345:fix/pi-tool-call-round-trip
Jul 24, 2026
Merged

fix(pi): preserve Antigravity state across turns#7
ualtinok merged 3 commits into
cortexkit:mainfrom
asp345:fix/pi-tool-call-round-trip

Conversation

@asp345

@asp345 asp345 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem

The Pi extension loses Antigravity state across multi-turn and tool-call requests:

  • backend functionCall.id values are replaced and then omitted from replayed calls and responses
  • streamed thinking and signatures attached to text-only responses are discarded
  • signatures from a previous model are replayed after switching models
  • historical function responses keep the same role after a model switch, unlike the native client
  • request step metadata is derived from part count and omits last_execution_id
  • GPT-OSS usage can arrive in an SSE frame after finishReason: STOP, but Pi cancels immediately

The missing tool IDs make Claude Opus reject the continuation after tool execution:

HTTP 400 INVALID_ARGUMENT
messages.1.content.0.tool_use.id: Field required

Fix

  • preserve backend function-call IDs and replay matching IDs in functionCall and functionResponse
  • carry a batch thought signature onto its first function call
  • stream and retain Pi thinking content and signed visible text for same-model history
  • strip thinking and signatures when history crosses model boundaries
  • emit correlated foreign-model function responses with the role observed from native model-switch traffic
  • track completed execution IDs in the shared request session and use content-based step counting as a Pi-only mode
  • consume GPT-OSS usage sent immediately after STOP, with a bounded one-second wait
  • explicitly return the SSE iterator before cancelling the response body to release the reader and socket

Trace verification

Additional captures were taken from one continued agy 1.1.5 conversation covering:

  1. two text-only Claude Opus turns
  2. a Claude Opus tool call and function-result continuation
  3. a switch to Gemini 3.6 Flash
  4. a switch to GPT-OSS 120B

The regression fixtures reproduce the captured execution-aware step sequence, same-model thinking/text-signature replay, tool-call signature placement, cross-model sanitation and roles, and GPT STOP-then-usage ordering.

Verification

  • npm run build
  • npm run typecheck
  • npm test — 1,270 passed, 25 todo
  • live Claude Opus tool loop completed successfully
  • live same-model Opus follow-up accepted signed history
  • live Opus → Gemini → GPT session completed successfully
  • live GPT-OSS response reported nonzero terminal usage

PR #6 changes the same Pi adapter files but does not currently include these behaviors. They should be retained if that rewrite lands first.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@asp345 asp345 changed the title fix(pi): preserve tool call metadata across turns fix(pi): preserve Antigravity state across turns Jul 24, 2026
@ualtinok
ualtinok merged commit 020a8e6 into cortexkit:main Jul 24, 2026
3 checks passed
iceteaSA pushed a commit to iceteaSA/antigravity-auth that referenced this pull request Jul 24, 2026
…tches

P2 cortexkit#7: fetchQuotaSummary used only options.endpoints[0] for every
project attempt, so a 5xx on the primary endpoint permanently lost
the request. Iterate the endpoint list per project attempt so a 500
or 429 on one endpoint falls through to the next — matches the
legacy fetchers' failover convention.

P2 cortexkit#8: aggregateQuotaSummary derived the pool from group.buckets[0]
unconditionally, silently dropping the whole group when an
unrecognized bucketId led the array. Use the first RECOGNIZED
bucket for pool derivation so the recognized windows are kept.

P2 cortexkit#9: modelCount parsed the raw description prose and counted
non-comma / non-colon tokens, so the 'Models within this group:'
prefix was counted as a model. Strip the prefix before splitting.

P2 cortexkit#10: the windowed summary fetch and the gemini-CLI quota fetch
ran sequentially — two 10s timeouts back-to-back, ~20s per account
on modal open. Run them concurrently via Promise.all.
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.

2 participants