Skip to content

fix(gemini): preserve thought_signature on stored tool calls; retry burst 429s; enable compaction - #1256

Merged
1jehuang merged 1778 commits into
1jehuang:masterfrom
adminwat:v0840-gemini-fixes
Sep 19, 2026
Merged

1jehuang merged 1778 commits into
1jehuang:masterfrom
adminwat:v0840-gemini-fixes

Conversation

@adminwat

@adminwat adminwat commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes on top of v0.84.0 for Gemini "works on turn 1, fails on turn 2":

  1. thought_signature dropped when storing tool calls (turn_streaming_mpsc.rs, turn.rs). The signature was captured from StreamEvent::ToolUseSignature but the persisted ContentBlock::ToolUse was hand-built with thought_signature: None in the mpsc/TUI paths (only turn_loops.rs carried it). Turn 2 replayed an unsigned history and Gemini 3.x returned HTTP 400 Function call is missing a thought_signature. Construction now goes through ToolCall::to_tool_use_block(). Three regression tests in jcode-message-types; falsified by restoring None (2 of 3 fail).
  2. Burst 429 from Code Assist killed the turn. Gemini was the only runtime with no 429 retry. Now retries up to 5x with backoff.
  3. Gemini/Cursor/Antigravity had no compaction path (supports_compaction() == false skipped even the emergency hard-compact).

Verified on a daemon-hosted mpsc session: two sequential tool calls on gemini-2.5-pro (server-upgraded to gemini-3.1-pro-preview), persisted history carries thought_signature on every tool call, zero stream_error.

Refs #518 (shared thought-signature persistence). This reference does not claim live-provider acceptance or close that issue.

1jehuang and others added 30 commits August 23, 2026 23:42
…ilent

When browser setup had already completed but Firefox was simply not
running, the bridge stopped responding and every message pointed the
agent at action='setup', which is a one-time install/repair flow. Agents
then re-ran setup (reopening the extension installer) instead of just
starting Firefox.

- Detect whether Firefox is running (per-OS) and, when the bridge is
  installed but silent because Firefox is closed, launch Firefox
  detached and wait for the bridge to reconnect before failing.
- ensure_firefox_ready() now auto-launches Firefox and proceeds with the
  requested action when the bridge reconnects, prefixing a note.
- browser setup and 'jcode browser status'/tool status now distinguish
  'Firefox is not running' from a genuinely broken install and say setup
  is one-time and not needed again.
- JCODE_BROWSER_AUTOLAUNCH=0 disables the auto-launch (also used to keep
  tests hermetic).
1jehuang and others added 13 commits September 6, 2026 18:40
Root cause of the recurring HTTP 400 on the *second* message of a Gemini
session:

  Function call is missing a thought_signature in functionCall parts.
  ... function call `default_api:websearch`, position 10.

The signature was ingested and streamed correctly (ToolUseSignature ->
ToolCall.thought_signature), but every turn loop then hand-built the
persisted ContentBlock::ToolUse, and three of the four copies hardcoded
`thought_signature: None`:

  jcode-tui/src/tui/app/turn.rs:333,401  (interrupt paths)
  jcode-tui/src/tui/app/turn.rs:1087     (main TUI path - every turn)
  jcode-app-core/src/agent/turn_streaming_mpsc.rs:1081

Only turn_loops.rs:785 carried it through. So the signature was captured,
then discarded the moment the assistant message was stored: turn 2
replayed a fully-unsigned history and the backend rejected it. Retrying
could never help, because the stored history was already stripped.

Rather than fix four copies and leave the fifth to rot, the construction
moves to ToolCall::to_tool_use_block(), the single place a completed tool
call becomes a stored block. Duplication is what let this diverge.

This is the real fix for the failure that PR #1 (branch
fix/gemini-missing-thought-signature-recovery) only mitigated: that
downgrade-to-text retry salvages an already-stripped history, but with
signatures preserved it should now rarely be reached.

Tests: three regression tests in jcode-message-types covering signature
preservation, session-JSON round-trip (resumed sessions hit the same 400
if the field is lost on disk), and clean omission for providers that do
not use signatures. Falsified by restoring `None`: 2 of 3 fail.

jcode-app-core has 9 pre-existing unrelated failures, identical with and
without this change (verified via stash). fmt clean; jcode-tui clippy
warning count unchanged at 48.
supports_compaction() gates the entire compaction block in
Agent::messages_for_provider, including the emergency hard-compact and
payload truncation that fire at the 95% critical threshold. These three
runtimes returned a hardcoded false and implement no native_compact, so
they had no compaction of any kind: a long session grew unchecked until the
provider rejected the prompt, with nothing able to rescue it. Unlike OpenAI
there was no config escape hatch either.

None of the three has native server-side compaction to conflict with, and
all three inherit the default complete_simple(), which is what
generate_compaction_artifact falls back to for the text summary. So opting
in gives them the full engine: proactive/semantic folding, hard compact and
emergency truncation.

Latent rather than observed today only because no Gemini session on the
test machine had yet exceeded 50 messages; Gemini advertises a 1M window,
so the failure arrives late and all at once.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T21:35:17.175274Z a5489f9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5489f9c89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// disabled the entire compaction block in `Agent::messages_for_provider`
// — including the emergency hard-compact and payload truncation at the
// critical threshold — leaving these sessions with no safety net at all.
true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep Cursor compaction off until summaries bypass prompt truncation

When a Cursor session is large enough to compact, the generic compactor sends the selected history through complete_simple, which reaches build_cli_prompt; that function retains only the final 120,000 characters (MAX_PROMPT_CHARS, lines 28 and 96-105). The compaction manager nevertheless marks every selected message as covered by the resulting summary, so an oversized compaction prompt silently omits the earliest conversation while hiding all of those original messages from subsequent requests. Keep this disabled or provide a chunked/non-truncating summary path for Cursor.

Useful? React with 👍 / 👎.

Comment on lines +400 to +401
if status == reqwest::StatusCode::TOO_MANY_REQUESTS && attempt < MAX_429_RETRIES {
let delay = Duration::from_millis(1500u64.saturating_mul(1u64 << attempt));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict retries to transient 429 responses

When Code Assist returns a persistent 429 for exhausted quota or billing limits, this condition retries solely by status and ignores the error body and any server retry interval. It therefore issues five doomed requests and delays the actionable error by 46.5 seconds; conversely, a transient limit with a retry interval longer than that can exhaust all attempts prematurely. Classify the body or honor the server-provided retry delay before entering this burst-retry loop.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 0/5

Not safe to merge until the blocking configuration reload, spawn-schema, retry timing, duplicate request replay, provider-switch context, and compaction reload issues are addressed.

Findings

  1. P1 Avoid Sticky Gemini Overrides ▶
  2. P1 Require Spawn Labels ▶
  3. P1 Honor Retry-After Timing ▶
  4. P1 Keep Switched-Provider Context ▶
  5. P1 Prevent Duplicate Generations ▶
  6. P1 Refresh Compaction Cap ▶
Fix with agent prompt
### Issue 1
crates/jcode-base/src/config/env_overrides.rs:830-851
Loading `gemini_force_oauth = true` or a Gemini project writes those values into the process environment. Every later reload then treats the values written by the earlier load as external overrides: changing OAuth to `false`, changing the project, or removing it has no effect. Long-running processes therefore continue using stale authentication and billing-project settings until restarted.

### Issue 2
crates/jcode-schema-dialect/src/registry.rs:93-100
Flattening Gemini's top-level `anyOf` removes the branch that requires `label` when `action` is `spawn`, while retaining `spawn` as an allowed action. Gemini can consequently emit a schema-valid `{"action":"spawn","prompt":"review the API"}` call that jcode rejects locally for its missing label. The requested worker is not created, and the user loses a tool round-trip.

### Issue 3
crates/jcode-provider-gemini-runtime/src/lib.rs:400-410
The new 429 handling retries only after fixed 1.5/3/6/12/24-second delays and never reads `Retry-After`. When the provider directs the client to wait longer, all six attempts can be consumed before requests are permitted again. A response with `Retry-After: 60` exhausts the final attempt at about 46.6 seconds, causing the turn to fail even though waiting for the server-provided deadline would allow a later retry.

### Issue 4
crates/jcode-provider-gemini-runtime/src/lib.rs:1096-1103
Enabling compaction for Gemini exposes OpenAI-native compaction state to a conversion path that cannot replay it. Gemini and Antigravity omit the encrypted compaction block entirely, while Cursor replaces it with a fixed marker. After switching providers, the request loses the compacted earlier conversation and contains only the active suffix, so the model can no longer use that prior context.

### Issue 5
crates/jcode-provider-gemini-runtime/src/lib.rs:397-399
If Code Assist completes a `generateContent` request before responding with a 5xx, this loop sends the identical POST again without an idempotency or deduplication key. The provider can run and bill the generation twice while jcode discards the first result; `onboardUser` uses the same helper and has the same replay behavior. Retry only failures where no response was received, or use the provider-supported idempotency mechanism.

### Issue 6
crates/jcode-base/src/compaction.rs:undefined-245
When `[compaction] max_context_tokens` changes during a running session, the existing compaction manager continues to use the value captured when it was created. After the global configuration reloads from 50,000 to 10,000, calling `set_budget(1_000_000)` still permits 50,000 tokens for that session, while a newly created manager uses 10,000. This can leave a long-running session 40,000 tokens above an operator's newly lowered context and cost limit.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This change adds Gemini configuration bridging and Gemini schema normalization. It introduces two blocking correctness problems: configuration reloads can retain stale Gemini authentication and billing-project values, and Gemini can be told that an unlabeled spawn request is valid even though jcode rejects it before creating a worker.

Reviews (4) · Last reviewed commit: "feat(gemini): [provider] gemini_project ..."

Comment on lines +401 to +410
let delay = Duration::from_millis(1500u64.saturating_mul(1u64 << attempt));
jcode_base::logging::warn(&format!(
"Gemini {} hit burst 429 (attempt {}/{}); retrying in {:?}",
method,
attempt + 1,
MAX_429_RETRIES,
delay
));
attempt += 1;
tokio::time::sleep(delay).await;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Honor Retry-After Timing

The new 429 handling retries only after fixed 1.5/3/6/12/24-second delays and never reads Retry-After. When the provider directs the client to wait longer, all six attempts can be consumed before requests are permitted again. A response with Retry-After: 60 exhausts the final attempt at about 46.6 seconds, causing the turn to fail even though waiting for the server-provided deadline would allow a later retry.

Artifacts

Evidence from the check

  • Runs an injected in-module test against the parent and current revisions with a local 429 endpoint that sends Retry-After: 60, exercising the actual post_json retry path; it demonstrates the compared behavior.

Command output from the check

  • Captured command output for the parent revision shows one local HTTP 429 Too Many Requests response with Retry-After: 60 and one request at 30 ms; before the change there was no 429 retry.

Command output from the check

  • Captured command output for the current revision shows six local HTTP 429 Too Many Requests responses despite Retry-After: 60, with the final attempt at 46.568 seconds; the retry budget is exhausted before provider availability.

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-provider-gemini-runtime/src/lib.rs
Line: 401-410

Comment:
**Honor Retry-After Timing**

The new 429 handling retries only after fixed 1.5/3/6/12/24-second delays and never reads `Retry-After`. When the provider directs the client to wait longer, all six attempts can be consumed before requests are permitted again. A response with `Retry-After: 60` exhausts the final attempt at about 46.6 seconds, causing the turn to fail even though waiting for the server-provided deadline would allow a later retry.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +1096 to 1103
// No native server-side compaction exists for this provider, so jcode's
// own summary compaction is the only thing standing between a long
// session and a hard context-limit rejection. Returning `false` here
// disabled the entire compaction block in `Agent::messages_for_provider`
// — including the emergency hard-compact and payload truncation at the
// critical threshold — leaving these sessions with no safety net at all.
true
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Keep Switched-Provider Context

Enabling compaction for Gemini exposes OpenAI-native compaction state to a conversion path that cannot replay it. Gemini and Antigravity omit the encrypted compaction block entirely, while Cursor replaces it with a fixed marker. After switching providers, the request loses the compacted earlier conversation and contains only the active suffix, so the model can no longer use that prior context.

Artifacts

Evidence from the check

  • The authored executable creates isolated before and after worktrees, injects focused runtime tests, and captures the provider conversion results; it demonstrates the exact exercised source path.

Command output from the check

  • The executed `HEAD^` run shows all three providers had compaction disabled while the same Gemini, Antigravity, and Cursor conversions respectively omit or reduce the OpenAI-native block; the unsafe conversion existed but was not enabled by this PR.

Command output from the check

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-provider-gemini-runtime/src/lib.rs
Line: 1096-1103

Comment:
**Keep Switched-Provider Context**

Enabling compaction for Gemini exposes OpenAI-native compaction state to a conversion path that cannot replay it. Gemini and Antigravity omit the encrypted compaction block entirely, while Cursor replaces it with a fixed marker. After switching providers, the request loses the compacted earlier conversation and contains only the active suffix, so the model can no longer use that prior context.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

…onId

Gemini/Claude-CLI/Grok emit StreamEvent::SessionId with the *provider* resume
handle. The mpsc turn loop re-broadcast it as ServerEvent::SessionId, which
the TUI treats as the jcode session id and stores in remote_session_id. Every
later reload/reconnect then ran 'jcode --resume <provider-id>', the server
found no such session and created a fresh empty one, and the user saw their
entire conversation vanish while the transcript sat intact on disk.
Comment on lines +403 to +405
let transient =
status == reqwest::StatusCode::TOO_MANY_REQUESTS || status.is_server_error();
if transient && attempt < MAX_429_RETRIES {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Prevent Duplicate Generations

If Code Assist completes a generateContent request before responding with a 5xx, this loop sends the identical POST again without an idempotency or deduplication key. The provider can run and bill the generation twice while jcode discards the first result; onboardUser uses the same helper and has the same replay behavior. Retry only failures where no response was received, or use the provider-supported idempotency mechanism.

Artifacts

Evidence from the check

  • The executed shell harness starts a local Code Assist-compatible server, returns a 500 then 200 for generateContent, and records each received request, demonstrating the precise retry contract.

Command output from the check

  • Combined output from executing the local harness shows HTTP 500 followed by HTTP 200, identical request body and user prompt ID, and no idempotency or deduplication headers, confirming an unkeyed replay.

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-provider-gemini-runtime/src/lib.rs
Line: 403-405

Comment:
**Prevent Duplicate Generations**

If Code Assist completes a `generateContent` request before responding with a 5xx, this loop sends the identical POST again without an idempotency or deduplication key. The provider can run and bill the generation twice while jcode discards the first result; `onboardUser` uses the same helper and has the same replay behavior. Retry only failures where no response was received, or use the provider-supported idempotency mechanism.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

…at a bounded size

Every turn re-sends the whole transcript. With Gemini's 1M window and the
0.80 trigger, a session could reach ~800k tokens per request before folding;
one real session hit 371k/turn (1.3 MB JSON) with compaction never firing.
[compaction] max_context_tokens bounds the budget in the single set_budget
funnel so every provider path (agent, TUI, model switch) honors it. 0 = off.
/// Update the token budget (e.g., when model changes)
pub fn set_budget(&mut self, budget: usize) {
self.token_budget = budget;
self.token_budget = Self::capped_budget(&self.compaction_config, budget);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Refresh Compaction Cap

When [compaction] max_context_tokens changes during a running session, the existing compaction manager continues to use the value captured when it was created. After the global configuration reloads from 50,000 to 10,000, calling set_budget(1_000_000) still permits 50,000 tokens for that session, while a newly created manager uses 10,000. This can leave a long-running session 40,000 tokens above an operator's newly lowered context and cost limit.

Artifacts

Initial compaction limit run

  • The initial run shows that a manager constructed with a 50,000-token limit applies that limit.

Reloaded compaction limit run

  • The reload run shows the existing manager remains at 50,000 while a new manager uses the reloaded 10,000 limit.

Compaction reload harness

  • The focused Rust harness keeps one manager alive across the configuration reload and compares it with a new manager.

Compaction reload harness manifest

  • The manifest defines the isolated executable used to exercise the reload behavior.

Compaction reload runner

  • The runner executes and records both the initial and reloaded configuration cases.

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-base/src/compaction.rs
Line: 245

Comment:
**Refresh Compaction Cap**

When `[compaction] max_context_tokens` changes during a running session, the existing compaction manager continues to use the value captured when it was created. After the global configuration reloads from 50,000 to 10,000, calling `set_budget(1_000_000)` still permits 50,000 tokens for that session, while a newly created manager uses 10,000. This can leave a long-running session 40,000 tokens above an operator's newly lowered context and cost limit.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

…f for Code Assist

Code Assist (cloudcode-pa) throttles per client identity: with the same OAuth
token, project and body, 'jcode/1.0 (gemini)' hit 429 RATE_LIMIT_EXCEEDED after
1-2 requests while the official GeminiCLI-tui UA ran unlimited (A/B, two rounds,
order swapped). Send the CLI UA and x-goog-api-client; JCODE_GEMINI_USER_AGENT
overrides.

Code Assist also rejects a root anyOf beside type/properties ('specified other
fields alongside any_of'), which the swarm tool's spawn/non-spawn branches use.
Enable flatten_top_level_combiners for the GEMINI dialect (nested anyOf is fine).
… the route gemini will take

An API key in gemini.env silently won over the Code Assist subscription and
there was no config knob to stop it, only JCODE_GEMINI_FORCE_OAUTH. Add
gemini_force_oauth to [provider] and mirror it into that env var from
apply_env_overrides (env wins), the same pattern as copilot_premium.

auth::gemini::force_oauth()/uses_api_key() are the single source of truth;
the runtime, auth status and auth-test credential_probe now agree, so
'jcode auth-test --provider gemini' reports the route actually used.

Also: register JCODE_WAKE_MODE in CONFIG_ENV_KEYS (fingerprint test was
already failing on this branch) and update the swarm anyOf test for the
Code Assist root-combiner flattening from d143f3e.
…UD_PROJECT

Workspace accounts fail every turn with 'requires setting GOOGLE_CLOUD_PROJECT'
when the env var is missing, and env-only config (launchctl setenv, .zshrc)
does not reach processes started from the menubar or shells older than the
setenv. Add gemini_project to [provider] and mirror it into the env from
apply_env_overrides (env wins), same pattern as gemini_force_oauth.

Verified: env -u GOOGLE_CLOUD_PROJECT jcode auth-test --provider gemini PASS.
Comment on lines +830 to +851
if let Ok(v) = std::env::var("JCODE_GEMINI_FORCE_OAUTH") {
self.provider.gemini_force_oauth = parse_env_bool(&v).unwrap_or(false);
} else if self.provider.gemini_force_oauth {
crate::env::set_var("JCODE_GEMINI_FORCE_OAUTH", "1");
}

// Gemini Code Assist project: same pattern. The runtime only reads
// GOOGLE_CLOUD_PROJECT, and env-only config (launchctl setenv, .zshrc)
// does not reach processes started from the menubar or older shells.
if let Ok(v) = std::env::var("GOOGLE_CLOUD_PROJECT") {
let v = v.trim();
if !v.is_empty() {
self.provider.gemini_project = Some(v.to_string());
}
} else if let Some(project) = self
.provider
.gemini_project
.as_deref()
.map(str::trim)
.filter(|p| !p.is_empty())
{
crate::env::set_var("GOOGLE_CLOUD_PROJECT", project);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Avoid Sticky Gemini Overrides

Loading gemini_force_oauth = true or a Gemini project writes those values into the process environment. Every later reload then treats the values written by the earlier load as external overrides: changing OAuth to false, changing the project, or removing it has no effect. Long-running processes therefore continue using stale authentication and billing-project settings until restarted.

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-base/src/config/env_overrides.rs
Line: 830-851

Comment:
**Avoid Sticky Gemini Overrides**

Loading `gemini_force_oauth = true` or a Gemini project writes those values into the process environment. Every later reload then treats the values written by the earlier load as external overrides: changing OAuth to `false`, changing the project, or removing it has no effect. Long-running processes therefore continue using stale authentication and billing-project settings until restarted.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +93 to 100
// Code Assist rejects a root `anyOf` when `type`/`properties` sit
// beside it ("specified other fields alongside any_of"), which is how
// the `swarm` tool expresses its spawn/non-spawn branches. Nested
// `anyOf` inside a property is fine, so only the root is widened.
flatten_top_level_combiners: true,
prune_dangling_required: true,
const_as_enum: true,
one_of_as_any_of: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Require Spawn Labels

Flattening Gemini's top-level anyOf removes the branch that requires label when action is spawn, while retaining spawn as an allowed action. Gemini can consequently emit a schema-valid {"action":"spawn","prompt":"review the API"} call that jcode rejects locally for its missing label. The requested worker is not created, and the user loses a tool round-trip.

Artifacts

Command output from the check

  • Executed the existing raw-schema test and captured its passing output, establishing that the unnormalized spawn branch requires a nonblank label.

Command output from the check

  • Executed the focused probe against the real Gemini dialect and swarm execution path; it shows the advertised requirement is action-only and the unlabeled spawn is rejected, confirming the mismatch.

Evidence from the check

  • Captured the authored test source that generated the focused schema-normalization and runtime-execution evidence.

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-schema-dialect/src/registry.rs
Line: 93-100

Comment:
**Require Spawn Labels**

Flattening Gemini's top-level `anyOf` removes the branch that requires `label` when `action` is `spawn`, while retaining `spawn` as an allowed action. Gemini can consequently emit a schema-valid `{"action":"spawn","prompt":"review the API"}` call that jcode rejects locally for its missing label. The requested worker is not created, and the user loses a tool round-trip.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@greptile-apps

greptile-apps Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings sit on lines the diff does not cover, so they could not be posted inline. Each one leaves this list once its file changes.

  • P1 Gemini swarm schema permits unlabeled spawn calls that runtime rejects ▶

    • Bug
      • After the Gemini dialect flattens the root action branches, the advertised schema requires only action yet retains spawn as an allowed action. Consequently, {"action":"spawn","prompt":"review the API"} is accepted by the advertised schema shape but fails locally rather than spawning a worker.
    • Cause
      • flatten_top_level_combiners unions branch properties but intentionally promotes required only from allOf; it removes the anyOf branch that conditionally required label for action=spawn. minLength: 1 remains only as a constraint on a supplied label, not a presence requirement.
    • Fix
      • Preserve the action-dependent requirement in Gemini's flattened representation, for example by emitting a Gemini-compatible schema that excludes spawn when conditional required constraints cannot be represented, or by using a provider-supported conditional representation that keeps label required for spawn. Add the executed regression probe as a permanent guard.

@1jehuang
1jehuang merged commit 8567dfa into 1jehuang:master Sep 19, 2026
1 of 2 checks passed
@1jehuang

Copy link
Copy Markdown
Owner

Merged into master via reviewed integration 8567dfa. Preserved thought signatures and provider/session identity fixes, but corrected review findings: config no longer exports sticky process environment, auth state is keyed by route/project, compaction caps refresh safely, and HTTP retries classify transient versus persistent quota errors and respect bounded Retry-After. Cursor compaction remains disabled because its summary path truncates input. Combined config/compaction tests, 146 provider/message/schema tests, local HTTP 429->503->200 replay, actual cache replacement, and a two-turn agent signature/session-ID test passed. No live Google account acceptance was possible, so this does not certify upstream credentials/quota behavior.

Integrated with original PR ancestry and contributor attribution preserved, applying only the actual contribution rather than the divergent old upstream tree. Validation is local targeted testing and isolated public-interface acceptance, not a claim that hosted CI is green.

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