fix: model-aware sentinels, cache optimization, session alignment, and image model support#5
fix: model-aware sentinels, cache optimization, session alignment, and image model support#5expiren wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
3 issues found across 11 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/src/plugin/config/loader.ts">
<violation number="1" location="packages/opencode/src/plugin/config/loader.ts:127">
P2: Model metadata containing `,}` or `,]` is silently changed while loading JSONC files because this replacement also matches inside quoted values. Strip trailing commas only outside JSON strings (or use a JSONC parser) so valid model fields remain intact.</violation>
</file>
<file name="packages/opencode/src/plugin/accounts.ts">
<violation number="1" location="packages/opencode/src/plugin/accounts.ts:162">
P2: Ineligibility metadata is lost on the first disk save, so after restart `isAccountIneligible()` returns false and the permanent-disable reason/timestamp cannot be recovered. Include these three fields in both the storage snapshot and loaded-account mapping.</violation>
</file>
<file name="packages/opencode/src/plugin.ts">
<violation number="1" location="packages/opencode/src/plugin.ts:2554">
P2: Some recoverable 403 responses can now permanently disable an account because the ineligibility matcher includes the generic phrase `access denied`. Tightening that check to explicit ineligibility phrases avoids false permanent disablement and preserves normal retry/fallback behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| /\\"|"(?:\\"|[^"])*"|(\/{2}.*|\/\*[\s\S]*?\*\/)/g, | ||
| (match: string, group: string | undefined) => (group ? "" : match) | ||
| ) | ||
| .replace(/,(\s*[}\]])/g, "$1"); |
There was a problem hiding this comment.
P2: Model metadata containing ,} or ,] is silently changed while loading JSONC files because this replacement also matches inside quoted values. Strip trailing commas only outside JSON strings (or use a JSONC parser) so valid model fields remain intact.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/opencode/src/plugin/config/loader.ts, line 127:
<comment>Model metadata containing `,}` or `,]` is silently changed while loading JSONC files because this replacement also matches inside quoted values. Strip trailing commas only outside JSON strings (or use a JSONC parser) so valid model fields remain intact.</comment>
<file context>
@@ -118,6 +118,56 @@ function mergeConfigs(
+ /\\"|"(?:\\"|[^"])*"|(\/{2}.*|\/\*[\s\S]*?\*\/)/g,
+ (match: string, group: string | undefined) => (group ? "" : match)
+ )
+ .replace(/,(\s*[}\]])/g, "$1");
+}
+
</file context>
| verificationRequiredReason?: string; | ||
| verificationUrl?: string; | ||
| /** Account permanently ineligible for Antigravity */ | ||
| ineligible?: boolean; |
There was a problem hiding this comment.
P2: Ineligibility metadata is lost on the first disk save, so after restart isAccountIneligible() returns false and the permanent-disable reason/timestamp cannot be recovered. Include these three fields in both the storage snapshot and loaded-account mapping.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/opencode/src/plugin/accounts.ts, line 162:
<comment>Ineligibility metadata is lost on the first disk save, so after restart `isAccountIneligible()` returns false and the permanent-disable reason/timestamp cannot be recovered. Include these three fields in both the storage snapshot and loaded-account mapping.</comment>
<file context>
@@ -158,6 +158,10 @@ export interface ManagedAccount {
verificationRequiredReason?: string;
verificationUrl?: string;
+ /** Account permanently ineligible for Antigravity */
+ ineligible?: boolean;
+ ineligibleAt?: number;
+ ineligibleReason?: string;
</file context>
| lowerBody.includes("not eligible") || | ||
| lowerBody.includes("ineligible") || | ||
| lowerBody.includes("not available for your account") || | ||
| lowerBody.includes("access denied") |
There was a problem hiding this comment.
P2: Some recoverable 403 responses can now permanently disable an account because the ineligibility matcher includes the generic phrase access denied. Tightening that check to explicit ineligibility phrases avoids false permanent disablement and preserves normal retry/fallback behavior.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/opencode/src/plugin.ts, line 2554:
<comment>Some recoverable 403 responses can now permanently disable an account because the ineligibility matcher includes the generic phrase `access denied`. Tightening that check to explicit ineligibility phrases avoids false permanent disablement and preserves normal retry/fallback behavior.</comment>
<file context>
@@ -2558,6 +2544,35 @@ export const createAntigravityPlugin = (providerId: string) => async (
+ lowerBody.includes("not eligible") ||
+ lowerBody.includes("ineligible") ||
+ lowerBody.includes("not available for your account") ||
+ lowerBody.includes("access denied")
+ );
+
</file context>
|
Thanks for the captures and detailed write-up. I audited the branch commit by commit and reimplemented the parts confirmed by fresh Landed separately:
The remaining branch behavior was not retained because it used request state that was unsafe under concurrent sessions, included labels/model metadata that did not match the fresh captures, disabled accounts using broad text matching, and added duplicate model-configuration sources. I also kept the OpenCode Claude cache-boundary adaptation: a live Opus tool-turn A/B measured 98.6% cached with it versus 89.2% after removing it. The proposed sentinel changes likewise did not match live signed Claude/Gemini replay. All replacement changes passed the full workspace suite and live OpenCode/Pi verification. |
Summary
Ports critical bug fixes and feature improvements from MITM-verified analysis against the real Antigravity IDE protocol.
Bug Fixes
sanitizeRequestPayloadForAntigravitycall in the wrapped request path — Claude requests were receiving empty string sentinels instead of dots.last_execution_id,trajectory_id,used_claudelabels andtoolConfig.functionCallingConfig.mode: VALIDATEDinsiderequestPayload, not the outer envelope. Applied in both wrapped and unwrapped paths.providerOptionsfrom request payload after extracting thinking config to prevent proxy fingerprint detection.createSyntheticErrorResponsecall sites now prefixed with[Antigravity Error]so users can distinguish plugin errors from AI responses.isClaudeThinkingonheaderStyle !== "antigravity"— the proxy handles all thinking management server-side. Client-side thinking mutations were busting prefix cache (60-70% hit rate). After fix: 97-100% cache hit rate.Features
CAPACITY_BACKOFF_TIERS_MS,getCapacityBackoffDelay, andresetAllRateLimitStateForAccount.~/.config/opencode/antigravity-models.json(c)(user-level) and.opencode/antigravity-models.json(c)(project-level) with JSONC support. Fixed merge order: built-in defaults < decoupled models < user opencode.json (highest priority). Dynamic whitelist viaObject.keys().antigravity-gemini-3.1-flash-imageto OpenCode model IDs (definition and image-saver already existed).Verification
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Aligns request formatting and session handling with the real Antigravity IDE to improve reliability and cache hit rates. Adds decoupled model loading and enables image model support, plus auto-disabling of ineligible accounts.
Bug Fixes
sessionIdfrom the project directory; used across requests and search.labelsandtoolConfig.functionCallingConfig.mode: VALIDATEDinside the request payload; strippedproviderOptionsafter reading thinking config.New Features
~/.config/opencode/antigravity-models.json(c)and.opencode/antigravity-models.json(c); merge order: built-ins < decoupled models <opencode.json.antigravity-gemini-3.1-flash-imageto the OpenCode model IDs.Written for commit 1d61562. Summary will update on new commits.