Skip to content

antigravity 0.1.5: derive sessionId from host session headers and skip injected preambles - #1017

Merged
yetone merged 1 commit into
magpie-community:mainfrom
JJERRYY:fix/antigravity-session-id
Nov 11, 2026
Merged

yetone merged 1 commit into
magpie-community:mainfrom
JJERRYY:fix/antigravity-session-id

Conversation

@JJERRYY

@JJERRYY JJERRYY commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Problem

sessionOf(req) previously looked only at the first role === "user" message and stopped after contents[0], ignoring x-magpie-session / x-magpie-subagent (and OpenCode's chat.headers sessionID).

In Codex (and other agents that prepend an AGENTS.md / <environment_context> message before the user's actual first prompt), req.contents[0].parts[0].text is identical across every thread (# AGENTS.md instructions...). As a result:

  1. Every unrelated Codex conversation, background thread_title request, and concurrent subagent collided onto the exact same request.sessionId constant.
  2. Interleaved requests across threads / subagents evicted each other's upstream KV cache beyond the shared ~32k preamble, causing frequent mid-session prompt cache drops.

Changes

  • Read x-magpie-session and x-magpie-subagent in sessionOf(req, headers) (ignoring synthetic magpie-<24hex> fallback IDs, matching packages/cline), and forward OpenCode 1.x's sessionID via "chat.headers".
  • When x-magpie-subagent is present (e.g. concurrent collab_spawn workers sharing a parent session ID) or when no host session header is provided, scan user parts past injected preambles (# AGENTS.md, <environment_context>, <permissions instructions>, <system-reminder>, Codex page snapshots, etc.) to reach the conversation's first real user prompt.
  • Bump @magpie-community/opencode-antigravity-auth to 0.1.5, update README.md, and add unit tests in shape.test.mjs and requests.test.mjs.

Verification

  • HOME=$(mktemp -d) bun test packages/antigravity: 88 pass, 0 fail
  • bun scripts/check.mjs antigravity: exit 0

@yetone
yetone merged commit 5efe4e7 into magpie-community:main Nov 11, 2026
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