Commit Graph

104 Commits

Author SHA1 Message Date
tctinh
3445cdaa88 feat: progressive rate limit retry with switch_on_first_rate_limit config
- Replace SHORT_RETRY_THRESHOLD_MS with progressive retry logic
- First 429: wait 1s, then switch account (if switch_on_first_rate_limit=true)
- Second 429: wait 5s, then switch (if switch_on_first_rate_limit=false)
- Single account: exponential backoff (1s, 2s, 4s... max 60s)
- Add switch_on_first_rate_limit config option (default: true)
- Update README with new config documentation

Fixes NoeFabris/opencode-antigravity-auth#147
2026-01-08 22:36:13 +07:00
tctinh
b228aa7337 fix: incorporate Gemini 3 model check for displayed thinking hashes in response transformation 2026-01-08 13:00:45 +07:00
tctinh
7ecc57c32d fix: update Gemini 3 model resolution logic and deduplicate thinking block handling 2026-01-08 12:52:28 +07:00
Soungmin Son (Eddy)
972c877a44 Merge branch 'dev' into fix/antigravity-v6.6.89-compat 2026-01-08 14:26:22 +09:00
happycastle
f2215b9841 feat: add CLIProxyAPI v6.6.89 Antigravity compatibility
Port Antigravity payload enhancements from CLIProxyAPI v6.6.89:
- Add systemInstruction with role 'user' and Antigravity identity text
- Add requestType: 'agent' to wrapped request body
- Add ANTIGRAVITY_SYSTEM_INSTRUCTION constant with full identity/guidelines

Reference: router-for-me/CLIProxyAPI@67985d8
2026-01-08 03:09:12 +00:00
tctinh
d39d1f5c90 fix: Gemini 3 tool schema format and restore thinking deduplication
- Wrap tools in functionDeclarations format for Gemini 3 API
- Flatten incoming functionDeclarations and convert parameters to proper schema
- Re-implement session-level thinking deduplication after partial revert
- Update README model names for clarity (Antigravity vs Gemini CLI)
- Fix model resolver to append default tier for Antigravity Gemini 3 models
2026-01-07 03:09:40 +07:00
tctinh
5fadf67a63 Merge remote-tracking branch 'origin/dev' into fix/thinking-signature-and-tool-schema-issues 2026-01-07 02:14:45 +07:00
tctinh
23a19dde3a fix: revert cross-request thinking deduplication (breaks streaming)
The cross-request deduplication was hashing PARTIAL streaming chunks,
not complete thinking blocks. This caused 'Failed to process error
response' errors during streaming.

Within-request deduplication (delta extraction) still works correctly.
2026-01-07 02:13:51 +07:00
CasualDeveloper
f78ddf23af fix: merge dev, align defaults with Google/Anthropic docs, simplify variants
Merge conflict resolution and defaults per official API docs.

**Gemini 3** (https://cloud.google.com/vertex-ai/generative-ai/docs/thinking):
> HIGH: Allows the model to use more tokens for thinking... This is the
> default level for Gemini 3 Pro and Gemini 3 Flash.

- Default thinkingLevel: 'high' for both Pro and Flash
- Model-specific levels: Flash (minimal/low/medium/high), Pro (low/high only)

**Claude** (https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking):
> To turn on extended thinking, add a thinking object... and the
> budget_tokens to a specified token budget.

- budget_tokens is required when enabling extended thinking (no default)
- Default thinkingBudget: 32768 (max) for Claude thinking models without variant

**Additional changes per maintainer feedback:**
- Simplify Claude variants to 'low' and 'max' only (medium/high not much different)
- Update all README examples and config snippets
2026-01-07 02:59:28 +08:00
CasualDeveloper
f05bd6b45e fix: add minimal level and set Pro default to high per Google docs
- Add 'minimal' to GEMINI_3_THINKING_LEVELS constant
- Change Pro default from 'medium' to 'high' (per Google API docs)
- Document model-specific level availability:
  - Flash: minimal, low, medium, high
  - Pro: low, high only
- Update README variant examples with correct levels per model

Addresses CodeRabbit review feedback on #131
2026-01-07 00:53:32 +08:00
Tinh To
b9a31312e1 Merge pull request #129 from NoeFabris/fix/thinking-signature-and-tool-schema-issues
fix: deduplicate thinking blocks in streaming output (#120)
2026-01-06 23:13:04 +07:00
tctinh
c5b5004948 fix: thinking level assignment and cross-request duplication
Fixes #109 and #115:

1. Thinking Level Assignment (model-resolver.ts):
   - Fixed antigravity-gemini-3-flash returning invalid "minimal" level
   - Fixed antigravity-gemini-3-pro-low skipping default thinkingLevel
   - Fixed -preview models not receiving any thinkingLevel
   - Changed invalid "minimal" to "low" for flash models
   - Added explicit handling for flash-preview and pro-preview models

2. Cross-Request Thinking Deduplication (streaming):
   - Added session-level hash tracking to prevent duplicate thinking across requests
   - Added displayedThinkingHashes option to StreamingOptions
   - Modified deduplicateThinkingText to track and skip already-displayed thinking
   - Persists hashes across all requests in same session

All 553 tests passing.
2026-01-06 23:05:20 +07:00
CasualDeveloper
6cab735ef1 feat: complete Gemini 3 variant config overhaul
Fixes #130

## Changes

### Model resolver (already in PR)
- Default thinkingLevel for base Gemini 3 models: Pro → 'medium', Flash → 'minimal'

### Native thinkingLevel support
- extractVariantThinkingConfig now extracts thinkingLevel string for Gemini 3
- Prefer native thinkingLevel when present
- Fall back to budget→level conversion with deprecation warning

### Correct variant config format (README)
- Remove providerOptions.google wrapper from all examples
- Gemini 3: use thinkingLevel string
- Claude: use thinkingConfig.thinkingBudget number

### Code cleanup
- Remove dead Anthropic/OpenRouter checks (all Antigravity routes through Google)
- Add deprecation warning for legacy thinkingBudget on Gemini 3

## Backward Compatibility
- Legacy thinkingBudget for Gemini 3 still works (deprecated)
- Tier-suffixed model names still work
2026-01-06 23:46:28 +08:00
CasualDeveloper
8499629a96 fix: ensure Gemini 3 models always have thinkingLevel set
Fixes #130

The skipAlias logic for Antigravity Gemini 3 models was bypassing
thinkingLevel assignment, causing empty responses from the API.

Changes:
- Remove skipAlias branch that skipped thinkingLevel
- All Gemini 3 models now get a default thinkingLevel:
  - Pro models: 'medium'
  - Flash models: 'minimal'
- Models with explicit tier suffix use the specified tier
2026-01-06 21:57:23 +08:00
tctinh
79cfd9aad1 fix: thinking signature, tool schema, and streaming issues
Comprehensive fixes for thinking block and tool schema validation:

1. Skip thought signature validator sentinel (Tasks 01-03)
   - Use Google's sentinel value for invalid/missing signatures
   - Harden cleanupRequiredFields() to filter to existing properties
   - Add ensureArrayItems() for array schema validation

2. Placeholder parameter validation (#112) (Task 04)
   - Inject _placeholder schema for tools without parameters

3. Tool pairing errors (Task 05)
   - Rewrite fixClaudeToolPairing() to properly match tool_use/tool_result

4. Edit tool JSON serialization (Task 06)
   - Add SKIP_PARSE_KEYS to preserve oldString/newString/content as strings

5. Empty thinking block handling (Task 07)
   - Return null for empty/invalid thinking blocks instead of empty string

6. Duplicated thinking blocks (#120) (Task 08)
   - Add delta-tracking to streaming transformer to deduplicate

Tests: 546 passing (up from ~500)
Fixes #112, #120
2026-01-06 20:16:04 +07:00
tctinh
7f6afa6338 fix: deduplicate thinking blocks in streaming output (#120)
Added delta-tracking to streaming transformer to extract only new portions
of thinking text, preventing duplicated blocks in UI.

- Added deduplicateThinkingText() function
- Added sentThinkingBuffer parameter to transformSseLine()
- Added 6 unit tests for deduplication logic
2026-01-06 20:05:14 +07:00
tctinh
815068ff05 feat: add pid_offset_enabled config option (disabled by default)
- Add pid_offset_enabled config option (default: false)
- Add env var override OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED
- Make PID-based account offset opt-in instead of always-on
- Update README with documentation

Fixes #122
2026-01-06 09:45:46 +07:00
tctinh
f100680c10 feat: mock proper-lockfile and enhance fs mocks in tests 2026-01-06 00:34:48 +07:00
tctinh
9eb09b5379 feat: implement variant thinking configuration extraction and model resolution 2026-01-06 00:21:15 +07:00
tctinh
c3d694b0d0 feat: add extractVariantThinkingConfig for provider-specific thinking config
- Supports Google, Anthropic, and OpenRouter thinking config formats
- Maps OpenRouter effort levels to token budgets
2026-01-05 23:26:40 +07:00
tctinh
f713005f38 feat: add file locking and multi-session PID offset
- File locking via proper-lockfile for concurrent write safety
- Atomic writes with temp file + rename pattern
- Merge-on-write pattern to preserve concurrent changes
- PID-based offset so different sessions start at different accounts
- Remove unused import (extractVariantThinkingConfig)
2026-01-05 23:23:37 +07:00
tctinh
eedafe5947 feat: smart account routing with error differentiation
- Add account_selection_strategy config: sticky, round-robin, hybrid
- Fix capacity vs quota error handling (Issue #111)
- Capacity errors: escalating backoff (5s→60s), retry same account
- Quota errors: switch to next account immediately
- Add touchedForQuota state tracking for hybrid strategy
- Add comprehensive tests for all strategies
2026-01-05 22:53:22 +07:00
Muhammad Septian
88c5dd091e Merge branch 'dev' into multi-account-issue 2026-01-02 10:32:37 +07:00
Muhammad Septian
36f2f549bd fix: improve account management by ensuring current auth is added to stored accounts 2026-01-02 02:37:01 +00:00
tctinh
ee80aeaba4 fix: apply cross-model signature sanitization to single requests
Fixes #70 - Gemini thoughtSignature persisting when switching to Claude

Root cause: sanitizeCrossModelPayloadInPlace() was only called for batched
requests, not for single requests. Gemini's thoughtSignature in tool metadata
persisted and caused Claude to reject with 'Invalid signature in thinking block'.

Bumps version to 1.2.8-beta.0
2026-01-01 10:34:48 +07:00
tctinh
902b5bf91a fix: correct output redirection in E2E test scripts and update model testing options 2026-01-01 09:55:28 +07:00
Tinh To
67f3f8b916 Merge pull request #85 from Parasitic-Hollow/fix/gemini3-thought-signature-caching
fix: extend thought signature caching to Gemini 3 models
2026-01-01 09:26:28 +07:00
tctinh
219069a2a3 feat: add legacy Gemini 3 model support for Antigravity quota and implement E2E test suite 2026-01-01 09:25:15 +07:00
Parasitic-Hollow
ac3788d52e fix: extend thought signature caching to Gemini 3 models
Add gemini-3 pattern matching to shouldCacheThinkingSignatures() to
enable proper thought signature handling for multi-turn conversations
with function calling on Gemini 3 models, alongside existing Claude support.
2025-12-31 21:40:46 -04:00
tctinh
85b82e6c2d chore: bump version to 1.2.7-beta.7 and remove unused getPublicModelName function
fix: gemini cli model endpoint not working
2025-12-31 23:23:50 +07:00
Younghoon CHOI _^
a7704694f1 Merge branch 'dev' into fix/port-in-use-error-message 2025-12-31 22:50:30 +09:00
bi9choi
0dc26d2374 fix: add user-friendly error message when OAuth port is already in use 2025-12-31 11:21:12 +09:00
Cris R.
87b5de48fb refactor: address CodeRabbit nitpicks by extracting helper and cleaning tests 2025-12-30 19:22:12 +01:00
Cris R.
782542bf47 refactor: apply CodeRabbit review suggestions for quota management 2025-12-30 19:21:57 +01:00
Cris R.
60352d75fe fix: resolve 404 errors in gemini-cli fallback using official aliases and v1beta endpoint 2025-12-30 19:21:32 +01:00
Cris R.
9ae70372e2 feat: implement model-specific gemini quota with prioritized antigravity pool fallback 2025-12-30 19:21:02 +01:00
tctinh
2455a7d4a3 fix: cross-model signature sanitization for Gemini-Claude session switching
Fixes 'Invalid signature in thinking block' error when switching models mid-session.

Root cause: Gemini stores thoughtSignature in metadata.google on tool call parts,
but existing strippers only checked top-level signatures. When switching to Claude
with a tool call, the foreign signature caused validation errors.

Changes:
- Add cross-model-sanitizer module for bi-directional sanitization (Gemini<->Claude)
- Integrate sanitizer into request pipeline for Claude models
- Add 42 new tests (28 unit + 14 integration)
- Add E2E test scripts for 5-model verification

Tested with: Gemini, Claude (Anthropic), Claude (Google), OpenAI, all passing.
2025-12-30 11:15:38 +07:00
tctinh
5025723186 fix: resolve OAuth callback hanging in WSL/SSH/remote environments
- Fix IPv4/IPv6 mismatch by binding server to all interfaces
- Add WSL/SSH/remote environment detection to skip unreachable local server
- Add 30s timeout fallback with manual URL input prompt
- Add --no-browser flag support for headless environments
- Add fetch timeout (10s) to fetchProjectID() to prevent indefinite hangs
- Improve openBrowser() with WSL wslview support
2025-12-29 23:20:38 +07:00
tctinh
22a12154fb feat: add quota fallback option to configuration schema and update Gemini 3 thinking levels 2025-12-28 22:27:00 +07:00
tctinh
0219e27396 fix: use conservative timing and centralized logic for token expiration 2025-12-28 21:32:53 +07:00
tctinh
802dfe1fdb Refactor rate limit handling and improve error responses
- Deleted the RATE_LIMIT_ROUTING_ANALYSIS.md document as it is no longer needed.
- Enhanced the regression test to provide detailed failure information, including the first failure's stderr output.
- Updated the plugin to handle 400 errors ("Prompt too long") with a synthetic response instead of returning a session-locking error.
- Introduced createSyntheticErrorResponse function to generate a synthetic SSE response for error messages, allowing continued session usage.
- Added tests for createSyntheticErrorResponse to ensure correct behavior and structure of the synthetic SSE events.
2025-12-28 18:28:56 +07:00
tctinh
457b3ac12b fix: improve rate limit handling and add prompt-too-long toast
- Add 2s deduplication window to prevent rate limit counter inflation from concurrent 429s
- Separate cooldown system from rate limits for non-429 errors (auth failures, 5xx)
- Add quota_fallback config option for automatic quota switching on rate limit
- Add toast notification for 400 'Prompt is too long' errors guiding users to /compact
- Add 5 new cooldown unit tests
- Enhance regression test suite with concurrent test infrastructure
- Add comprehensive rate limit analysis documentation
2025-12-28 16:09:52 +07:00
tctinh
93415be685 fix: resolve thinking block preservation and schema duplication issues 2025-12-28 12:20:44 +07:00
tctinh
7f069c8a96 Merge remote-tracking branch 'origin/dev' into feature/gemini-cli-routing 2025-12-28 00:36:30 +07:00
tctinh
c83b29f916 fix merge conflict 2025-12-28 00:12:39 +07:00
Tinh To
a658937bc0 Merge branch 'dev' into fix/account-duplication 2025-12-28 00:09:22 +07:00
tctinh
16f4bb07a1 feat: add E2E testing scripts and simplify Gemini Flash model config
- Add test-models.ts for validating all supported model endpoints
- Add test-regression.ts for multi-turn regression testing (Issue #50)
- Consolidate Gemini 3 Flash variants (low/medium/high) into single model
- Fix schema structure by flattening nested signature_cache properties
- Extract streaming transformer utilities to dedicated module
2025-12-28 00:04:57 +07:00
Tinh To
d99302e7f4 Merge pull request #63 from Parasitic-Hollow/fix/webfetch-format-validation
fix: WebFetch tool format parameter validation with Claude models
2025-12-27 23:27:24 +07:00
tctinh
14f9067089 feat: add Claude tool hardening and improve context error recovery
- Add tool hardening for Claude models with parameter signature injection
  and system instruction prepending (configurable via claude_tool_hardening)
- Add context error detection (prompt_too_long, tool_pairing) with toast
  notifications to guide users on recovery actions
- Improve session recovery to handle cases where messageID isn't provided
  by fetching and finding the latest assistant message
- Change empty schema placeholder from reason (string) to _placeholder
  (boolean) to reduce token usage
- Add duplicate injection prevention for parameter signatures and tool
  hardening instructions
- Fix cache key to strip tier suffix from model name (e.g., -high, -low)
  preventing cache misses on tier change
- Add thoughtsTokenCount to usage metadata extraction
- Extract and export applyToolPairingFixes helper for centralized tool
  pairing logic
- Add comprehensive tests for recovery error detection and request helpers
2025-12-27 16:43:07 +07:00
Parasitic-Hollow
c9c2745dbc fix: WebFetch tool format parameter validation with Claude models
Fixes NoeFabris/opencode-antigravity-auth#62 - WebFetch tool failing with
"Invalid option: expected one of 'text'|'markdown'|'html'" error.

Root cause: Two bugs in JSON schema cleaning for Antigravity API:

1. flattenAnyOfOneOf lost enum values when anyOf/oneOf used const pattern
   - Pattern like anyOf: [{const: "text"}, {const: "markdown"}] was
     flattened to just the first option, losing other valid values
   - Fix: Added tryMergeEnumFromUnion() to detect enum patterns and
     merge all values into a single enum array

2. removeUnsupportedKeywords incorrectly removed property NAMES
   - The "format" JSON Schema keyword was in UNSUPPORTED_KEYWORDS
   - This also removed properties NAMED "format" inside schemas
   - Fix: Added isInsideProperties flag to preserve property names
     while still removing JSON Schema keywords

Added comprehensive test coverage for enum merging from anyOf/oneOf.
2025-12-27 05:10:00 -04:00