Commit Graph

1562 Commits

Author SHA1 Message Date
Luis Pater
b11aacdd2b fix(antigravity): enforce claude min thinking budget and max_output_tokens cap
- Strip thinkingConfig and thinking_config in CapAntigravityMaxOutputTokensDoc when clamping a numeric Claude thinking budget would fall below 1024 while leaving non-numeric, dynamic, and level-based configs untouched.
- Recognize numeric snake_case max_output_tokens aliases capped by model MaxCompletionTokens in effectiveMaxTokensDoc and apply the same catalog output cap in buildRequestForModelDoc.
- Add unit tests covering sub-1024 Claude budget stripping, snake_case max_output_tokens handling, and catalog-limit clamping.

Closes: #8165
2026-11-26 07:29:10 +08:00
Luis Pater
50aea0fa71 fix(antigravity): isolate agent envelope sessions across Home accounts without enum scope
- Derive a hashed grantScope fallback in ApplyAntigravityAgentEnvelope when antigravity_model_enum_scope is empty and RegistrationEpoch is zero, using account-level identifiers before falling back to ephemeral tokens while keeping local registration epochs unchanged.
- Add regression tests covering distinct Home accounts, sanitized Home dispatches, shared-project token fallback, same-account access token rotation, and preserved local Manager.Update sessions.

Closes: #8167
2026-11-26 07:26:56 +08:00
Luis Pater
e7767a3ba8 fix(antigravity): prevent stale credits balance resurrection after removal or failure reset
- Delete stale cached credits balances from both local memory and Home KV when loadCodeAssist reports absent GOOGLE_ONE_AI credits, preserving the absent-entry invariant for skipped entries.
- Clear cached credits balances alongside hint resets in clearAntigravityCreditsFailureState, using versioned Home KV CAS transitions so failed invalidations retain retry state and concurrent refreshes are never wiped.
- Add regression tests covering standalone, Home KV, error-retention, concurrent-refresh, and rolling-upgrade scenarios.

Closes: #8158
2026-11-26 03:36:24 +08:00
Luis Pater
4183021383 fix(antigravity): eliminate credits hint recovery race in executor and tests
- Extract shared credential-scoped credits refresh key helpers and update recovery tests to await the scoped refresh entry instead of a bare auth ID.
- Atomically check and clear unavailable credits hints under the hint scope lock so concurrent credit balance refreshes cannot be clobbered.
- Add regression tests covering atomic unavailable-hint clearing and concurrent recovery against positive hint publication.

Closes: #8162
2026-11-26 03:24:58 +08:00
Luis Pater
568c717a96 fix(aistudio): finalize zeroOutputGuard when wsStream closes without StreamEnd
- Flush remaining buffered relay SSE frames and unconditionally finalize zeroOutputGuard on non-canceled EOF when wsStream closes without MessageTypeStreamEnd.
- Extract the stream-consumption goroutine into an unexported consumeStream helper and add regression tests covering candidate shells, non-candidate shell flushing, post-commit abnormal finish, and canceled contexts.

Closes: #8161
2026-11-26 03:06:19 +08:00
Luis Pater
c9fc5d5abf fix(antigravity): preserve non-empty groundingMetadata when trailing SSE chunk carries empty object
- Track whether captured groundingMetadata contains any fields via ojson ForEach so trailing empty objects cannot overwrite earlier non-empty metadata while preserving explicit empty objects when no non-empty metadata was seen.
- Write preserved non-empty groundingMetadata back into templateDoc unconditionally so trailing empty groundingMetadata objects are replaced.
- Add non-streaming assembly unit tests covering trailing empty objects, latest non-empty precedence, and explicit empty-object compatibility.

Closes: #8160
2026-11-26 03:00:14 +08:00
Luis Pater
a07d358295 fix(executor): sanitize nested input content parts and empty function_call id in Gemini Interactions
- Extract sanitizeGeminiInteractionsItemDoc on *ojson.Doc and apply it to both top-level input steps and nested input[].content[] parts, compacting dropped nested thoughts and preserving nested function_call IDs.
- Promote non-blank call_id verbatim to id when function_call.id is missing, empty, or whitespace-only before stripping call_id, and skip content traversal on kept top-level thought steps.
- Add regression tests covering nested function_call/thought sanitization, Vertex bare-Tink scoping, verbatim call_id promotion, and combined top-level/nested thought compaction.

Closes: #8153
2026-11-26 02:41:47 +08:00
Luis Pater
389ded4330 fix(executor): support snake_case tool parts and assistant role in Gemini content turn helpers
- Treat leading "assistant" turns equivalently to "model" turns in EnsureGeminiLeadingUserContentDoc.
- Recognize snake_case function_call, function_response, and function_response.parts media in Gemini turn boundary helpers.
- Add regression unit tests covering leading assistant turns, snake_case tool responses with and without nested media, and trailing thought-bearing tool parts.

Closes: #8155
2026-11-26 02:38:09 +08:00
Luis Pater
3e7faea98b fix(executor): treat audioTranscription parts as visible output in Gemini zero-output guard
- Recognize non-empty string audioTranscription and audio_transcription parts in InspectGeminiZeroOutputPayload while preserving thought-only classification.
- Support snake_case audio_transcription parts in OpenAI Chat Completions Gemini streaming and non-streaming response translators so admitted transcripts are delivered to clients.
- Add regression unit tests covering zero-output inspection, non-stream checks, stream guard emission, and OpenAI transcript translation.

Closes: #8150
2026-11-26 02:26:05 +08:00
Luis Pater
b7195395d3 fix(executor): avoid flushing truncated Interactions SSE frames on scanner error
- Guard trailing frame emission in Gemini and Vertex Interactions streaming executors so buffered partial frames are only flushed on clean EOF with an active context, while preserving trailing newline detection via ScanInteractionsSSELines to prevent unterminated whitespace from triggering in-loop flushes.
- Record non-nil scanner errors in internal API response diagnostics before EndApplyPatchStream finalization so raw read failures are never lost while keeping the sanitized 502 downstream apply_patch contract intact.
- Add regression tests covering mid-frame scanner errors, canceled-context diagnostic recording, apply_patch scanner error diagnostics, unterminated whitespace tails, and clean EOF trailing frames.

Closes: #8138
2026-11-26 01:32:07 +08:00
Luis Pater
24fb240c51 fix(executor): escape opts.Alt query parameter in Gemini and Vertex executors
- Escape opts.Alt with url.QueryEscape at all six upstream URL construction sites across GeminiExecutor and GeminiVertexExecutor to prevent query parameter injection and URL parsing errors.
- Rename the shadowed local url string variables to endpointURL at those sites and add regression tests covering Execute and ExecuteStream for Gemini and Vertex API key and service account paths.

Closes: #8137
2026-11-26 01:22:57 +08:00
Luis Pater
8cb15f2787 fix(vertex): filter non-terminal SSE usageMetadata in streaming executors
- Filter non-terminal SSE usageMetadata in both Vertex service-account and API-key streaming paths before translation while preserving internal usage accounting and trailing usage-only frames after a finish signal without traceId.
- Add regression tests covering API-key and service-account streaming across Gemini, OpenAI, and Claude formats for single-frame and split-terminal usage delivery.

Closes: #8134
2026-11-26 01:11:22 +08:00
Luis Pater
542dacc093 fix(executor): evaluate filter blocks before recording finish signals in Gemini and Vertex streams
- Check GeminiFilterBlockMessage and geminiPromptBlockErrorMessage before flushing buffered filter frames or setting sawFinishReason across GeminiExecutor and both GeminiVertexExecutor streaming loops so terminal and consecutive filter-blocked frames with promptFeedback.blockReason return HTTP 400.
- Preserve finish-signal tracking when a buffered frame is flushed by a subsequent normal response frame.
- Add streaming regression tests covering single and consecutive filter-blocked frames with SAFETY and PROHIBITED_CONTENT across Gemini, Vertex API key, and Vertex service account paths.

Closes: #8133
2026-11-26 01:09:08 +08:00
Luis Pater
f4ff417eac fix(vertex): inspect only URL path for API version suffix
- Extract and inspect only the URL path in a shared helps.VertexAPIVersionSuffix helper so bare version-like hostnames such as http://vertex1 or http://v1-gateway still receive /v1 in both Vertex API-key model URLs and Vertex OpenAPI base URLs.
- Add regression tests covering bare version-like hostnames, ports, trailing slashes, and explicit version paths for vertexAPIKeyModelsURL and Vertex OpenAPI base URL builders.

Closes: #8122
2026-11-25 22:51:33 +08:00
Luis Pater
0c6681923c fix(translator): guard null Gemini generation fields and support snake_case in Claude requests
- Require numeric validation for maxOutputTokens, topP, topK, and thinkingBudget so null or invalid values no longer coerce to 0 or disable thinking while keeping temperature omitted per #4071 and #4383.
- Support snake_case Gemini SDK fields for generation_config, thinking_config, function_declarations, parameters_json_schema, and mixed thinking summary paths.
- Align stripTranslatedDefaultMaxTokens in ClaudeExecutor with the translator's Gemini generationConfig and positive maxOutputTokens alias selection.

Closes: #8112
2026-11-25 21:06:09 +08:00
Luis Pater
aa1389a355 fix(translator): resolve shortMap tool_choice, snake_case fields, args, and null thinkingBudget
- Resolve single and multi-tool tool_choice names through shortMap (emitting allowed_tools subsets for multi-entry ANY whitelists) and remove the legacy raw-byte helper.
- Support snake_case Gemini SDK fields across request and response tool name mapping and default missing or non-object functionCall.args to "{}".
- Require numeric thinkingBudget and string thinkingLevel values in both Gemini-to-Codex translation and shared thinking config extraction so null values do not disable reasoning.

Closes: #8098
2026-11-25 19:49:55 +08:00
Luis Pater
db276e8b1b fix(executor): fix Vertex Imagen panic, Meta response.done, and Antigravity tests
- Guard nil bufio.Scanner before calling scanner.Err() on Vertex Imagen streaming paths for both service account and API key auth.
- Recognize and normalize Meta response.done terminal events across streaming and non-streaming translation paths with regression tests.
- Align Antigravity issue 7000 boundary and apply_patch empty-stream test assertions with single-part system instructions and issue 7990 transient zero-output retries.
2026-11-25 19:02:53 +08:00
Luis Pater
b47cd8e8f9 Merge pull request #8119 from router-for-me/home
feat(home): delegate Home dispatch to plugin executors
2026-11-25 18:13:04 +08:00
hkfires
27e7618dc8 fix(home): report antigravity project discovery failures
Publish upstream 401 and 429 responses from Antigravity project
discovery during home auth preparation so credential failures are
attributed using the effective token and upstream model.

Thread the upstream model through prepareHomeRequestAuth via
context and generalize the home credential failure publisher to
support non-401 statuses. Add coverage for execute, stream, and
count paths, including delegated plugins and refreshed tokens.
2026-11-25 17:36:53 +08:00
hkfires
ad2edae0b6 feat(home): delegate Home dispatch to plugin executors
Advertise ready executor plugins and their supported credential
providers in Home auth dispatch, and let Home select a plugin via
executor_plugin. Resolve the live plugin bound to the credential
provider, prepare credentials through the provider preparer
including Antigravity token refresh, and preserve the upstream
model and model info for plugin execution.

Add the ExecutorAuthProviders capability over the plugin RPC
boundary and surface unavailable Home plugin executors as a
terminal 503 without retrying other credentials.
2026-11-25 16:29:20 +08:00
Luis Pater
531aea156a fix(util): normalize numeric protobuf Schema.Type enums in Gemini schemas
- Decode numeric protobuf Schema.Type enum values (1..7) to lowercase JSON Schema type strings via *ojson.Doc in NormalizeJSONSchemaNumericConstraints while preserving literals and special property keys.
- Normalize schemas prior to nested wrapper cleaning, Claude 5.5 structured output prompt fallback, Interactions response_format emission, and snake_case Gemini pass-through schema fields.
- Add regression tests covering schema cleaners, Antigravity executor paths, and Gemini-ingress translators.

Closes: #8032
2026-11-25 11:41:46 +08:00
Luis Pater
ffa5511251 feat(thinking): parse extra_body.google.thinking_config on OpenAI Chat requests
- Parse thinking_level/thinkingLevel and thinking_budget/thinkingBudget from Google extra_body thinking_config variants as a lower-precedence fallback in OpenAI effort extraction and Antigravity intent routing.
- Apply the same fallback precedence during OpenAI Chat to Antigravity and Gemini request translation so upstream thinkingConfig matches extracted reasoning_effort metadata.
- Add unit and executor regression tests covering snake_case/camelCase variants, precedence rules, and Antigravity grouped-model routing.

Closes: #8018
2026-11-25 11:07:29 +08:00
Luis Pater
d71e9dcd7d fix(auth): recognize codex-acp user agents in Codex SIWC bypass
- Match codex-acp and codex_acp client identifiers in IsCodexClientUserAgent so ACP Codex requests bypass use_siwc and use outer Codex OAuth credentials.
- Add regression tests with the full @agentclientprotocol/codex-acp User-Agent covering SIWC bypass selection and Codex HTTP/WebSocket execution paths.

Closes: #8011
2026-11-25 11:07:27 +08:00
Luis Pater
e9dd8bada7 fix(executor): refresh replay cache snapshot after pairing-failure invalidation
- Add DeleteAntigravityReasoningReplayItemsIfUnchangedWithSnapshot in internal/cache to atomically return the newly written tombstone snapshot across local memory and Home KV modes.
- Update scope.cacheSnapshot in prepareAntigravityGeminiReasoningReplayPayloadDocWithOptions when conditional invalidation succeeds so the next turn's Commit CAS persists instead of silently dropping replay state.
- Add regression tests covering memory/KV commit recovery after pairing degradation and concurrent-write isolation.

Closes: #7997
2026-11-24 11:29:54 +08:00
Luis Pater
9bce482522 fix(antigravity): reject invalid HTTP 200 responses in CountTokens
- Validate that HTTP 2xx CountTokens responses are valid JSON objects before checking in-band errors or token counts, returning 502 Bad Gateway on empty, HTML, malformed, or non-object bodies.
- Strictly parse numeric totalTokens as a non-negative int64 via strconv.ParseUint before translation, rejecting missing, fractional, negative, or overflowing values while preserving explicit zero counts.
- Add hermetic regression tests covering invalid HTTP 200 CountTokens responses across formats alongside valid zero and positive counts.

Closes: #7992
2026-11-24 10:41:12 +08:00
Luis Pater
d1bdee850b fix(antigravity): reject empty SSE responses in non-stream execution
- Return a retryable 502 zero-output status error in executeClaudeNonStream when an HTTP 200 SSE stream yields no valid JSON payload, preserving context errors and avoiding replay commits or credits failure-state resets.
- Add hermetic regression tests covering empty, HTML, and sentinel-only SSE bodies across Claude and OpenAI formats while confirming valid SSE responses without finishReason still succeed.

Closes: #7991
2026-11-24 10:21:19 +08:00
Luis Pater
20be744e80 fix(antigravity): reject empty successful streams
- Return a retryable 502 when an upstream HTTP 200 stream contains no valid SSE JSON payload.
- Cover empty and HTML responses while preserving valid terminal synthesis without finishReason and credits failure state.

Closes: #7990
2026-11-24 10:00:44 +08:00
Luis Pater
14a95b19e2 fix(antigravity): preserve thinking-group output caps
- Preserve smaller caller output limits while applying thinking-group catalog caps.
- Clamp Claude thinking budgets and normalize output token aliases before payload rules run.

Closes: #7985
2026-11-24 09:48:07 +08:00
Luis Pater
335b69879d fix(codex): handle nil auth in websocket streams
- Guard websocket stream authentication logging so nil credentials do not panic.
- Add regression coverage for compact and required-websocket nil-auth paths.

Closes: #7970
2026-11-24 07:26:32 +08:00
Luis Pater
32625f13de fix(meta): report clean eof before terminal event
- Emit a truncated 502 stream error when Meta closes before response.completed or response.incomplete.
- Record failed usage with accumulated details and cover the regression with an end-to-end stream test.

Closes: #7971
2026-11-24 07:22:22 +08:00
Luis Pater
38067a2997 fix(antigravity): align outbound request wire format
- Preserve normalizer request IDs and correlation labels while generating slash-delimited native fallbacks.
- Normalize native tool output keys and single-part system instructions across Antigravity request paths.

Closes: #7967
2026-11-24 07:06:16 +08:00
Luis Pater
06225fcf6e fix(antigravity): preserve signature cache scope on first refresh
- Retain the pre-refresh grant identity when initializing signature cache metadata for legacy credentials.
- Add a regression test proving cached Claude thinking signatures remain recoverable after the first token rotation.

Closes: #7968
2026-11-24 07:06:15 +08:00
sususu98
62c419e049 fix(translator,executor): preserve native Claude max_tokens and remove Vertex silent cap
- Replace ClaudePositiveMaxTokens with ClaudeMaxTokensRaw to forward raw JSON numeric max_tokens verbatim (including 0 for Claude cache pre-warming and >65536 values for Gemini 4 long decodes) without silent filtering, truncation, or clamping.
- Remove silent maxOutputTokens capping from GeminiVertexExecutor so Vertex requests (including Gemini 4 long decodes up to 1,048,576 tokens) follow official Vertex API semantics.
- Avoid intermediate slice allocation in ClaudeStopSequences with ForEach.
- Synchronize captured request bodies via buffered channels in claude_generation_config_regression_test.go and add end-to-end gemini-interactions coverage.
2026-11-24 00:17:13 +08:00
sususu98
ac415c083a fix(translator,executor): harden Claude generation constraints and Vertex max output token cap
- Centralize Claude max_tokens, stop_sequences, and output_config.format parsing in internal/translator/common/request.go to filter invalid/non-positive values and clamp huge max_tokens deterministically.
- Use the shared helpers in Gemini, Antigravity, and Interactions Claude request translators, adding Interactions response_format mapping and removing dead schema deletes.
- Apply provider output token capping across all Vertex execute/stream paths before the payload config barrier, using float comparison to close fractional and overflow bypasses.
- Add unit and executor regression tests covering translators, Antigravity Claude 5.5 prompt fallback, and Gemini/Vertex API key and service account paths.
2026-11-23 23:29:33 +08:00
Luis Pater
f73b8132d0 fix(claude): stabilize advisor system prompt placement
- Select top-level caller system placement from the initial advisor tool declaration to keep the conversation prefix stable.
- Apply the same advisor-aware layout to message and count-token requests and cover both phases with a regression test.

Closes: #7941
2026-11-23 23:00:31 +08:00
Luis Pater
85225381d8 fix(antigravity): isolate signature cache by credential
- Scope Claude signature recovery and writes to the active credential.
- Preserve scoped cache continuity across verified token refreshes.
- Fail closed for unscoped recovery and credential replacement.
- Add stream and non-stream multi-account isolation regression coverage.

Closes: #7960
2026-11-23 22:46:33 +08:00
Luis Pater
e049c336b6 fix(vertex): normalize Imagen predict protocol
- Convert Imagen requests and responses consistently across API-key and service-account execution paths.
- Handle non-streaming Imagen JSON directly on stream APIs while preserving final payload rule ordering.

Closes: #7955
2026-11-23 22:46:31 +08:00
Luis Pater
bffe6e7ea1 fix(antigravity): isolate connection pools after credential replacement
- Scope pooled transports by stable auth identity and a digest of the refresh grant.
- Add a regression test proving replacement credentials use a distinct TCP connection.

Closes: #7961
2026-11-23 22:46:30 +08:00
Luis Pater
aeed971579 fix(gemini): suppress pending filter frames on stream errors
- Prevent buffered Gemini policy text from reaching clients after scanner failures.
- Reject truncated successor frames and cover Gemini and Vertex authentication paths.

Closes: #7956
2026-11-23 22:46:28 +08:00
Luis Pater
ae3d80f70d fix(antigravity): honor retry hints on capacity errors
- Parse structured and header retry hints for HTTP 503 capacity responses.
- Verify the propagated delay is used by model cooldown scheduling.

Closes: #7957
2026-11-23 22:46:24 +08:00
Luis Pater
dc2455d998 fix(antigravity): validate compaction summaries
- Reject incomplete summaries before sealing Antigravity compaction responses.
- Preserve cached and reasoning token details in compaction responses and streams.

Closes: #7934
2026-11-23 22:46:15 +08:00
hkfires
f110136af3 fix(thinking): clamp budgets to levels for OpenAI models
OpenAI Chat/Responses and xAI appliers accept effort levels
only, so numeric budgets on hybrid models were not clamped
to supported levels. Clear Min/Max on a copy of the model
info before conversion, preserving catalog capabilities.

Use ClampLevel for the Devin swe-1-7 medium variant so
budget-derived levels select the correct upstream UID.

Add regression tests for Copilot, Devin, and OpenAI-compat
chat covering body and suffix budgets across formats.
2026-11-23 22:45:56 +08:00
hkfires
a516bf3b4f refactor(devin): use canonical thinking clamping
Replace custom Devin level ordering and clampEffort logic with
thinking.ParseLevelSuffix and thinking.ClampLevel, adapting to the
updated ConvertBudgetToLevel signature. Ties now resolve to the
lower effort per canonical rules, updating affected tests.

Document devin as a supported OAuth channel in config.example.yaml
with model alias and excluded model examples.
2026-11-23 22:45:55 +08:00
hkfires
a308c55bcd fix(thinking): correct budget to max level conversion
Add an xhigh upper bound of 32768 so larger budgets map to max
instead of xhigh. Convert translated budgets to adaptive effort
for hybrid Claude and Interactions models in validation rather
than in the Gemini-to-Claude translator, which now preserves the
budget for model-aware handling.

Validate user-defined models before normalization so translated
budgets are clamped to model limits while custom settings are
preserved. Reuse the canonical budget conversion for Devin and
prefer the lower effort on ties only for budget-derived levels.
2026-11-23 22:45:55 +08:00
Luis Pater
2f86992c94 feat(antigravity): route grouped models by requested thinking level 2026-11-23 13:23:05 +08:00
Luis Pater
5ddbfbaf4a fix(antigravity): preserve stream filter errors across terminal frames
- Retain pending Gemini filter errors when trailing stream frames contain no visible content.
- Reuse zero-output inspection so valid code and media content still disambiguate buffered filter frames.
- Add streaming regressions for terminal metadata, empty media placeholders, and executable code content.

Closes: #7918
2026-11-23 12:57:55 +08:00
Luis Pater
4087007c6a fix(antigravity): surface in-band count token errors
- Detect non-null error payloads before translating successful CountTokens responses.
- Preserve upstream status and existing 429, 403, and 401 credential bookkeeping.

Closes: #7920
2026-11-23 12:56:08 +08:00
Luis Pater
d0da9a9a1d fix(antigravity): preserve grounding metadata across stream aggregation
- Retain candidate grounding metadata when terminal SSE chunks omit it.
- Add a regression test for citations from an earlier response chunk.

Closes: #7919
2026-11-23 12:53:42 +08:00
Luis Pater
c2dcf7488e fix(antigravity): preserve non-stream filter errors across terminal frames
- Keep pending Gemini filter errors when trailing usage or finish frames contain no real content.
- Cover terminal metadata and empty text carrier regressions for Claude non-stream execution.

Closes: #7915
2026-11-23 12:33:16 +08:00
Luis Pater
16bcf5a072 fix(antigravity): re-clamp Claude thinking budget after output cap
- Clamp Claude thinking budgets when the model output limit reduces maxOutputTokens below an accepted requested ceiling.
- Add regression coverage for Antigravity Sonnet and Opus models, including case-insensitive model resolution.

Closes: #7916
2026-11-23 12:32:55 +08:00