|
| 1 | +# WP1 — #1894 direct Gemini wire id (Wave 5A-1) — rev 2 after audit |
| 2 | + |
| 3 | +> Rev 2 folds audit blockers 1-4. The 404-triggered retry proposed in rev 1 is |
| 4 | +> **dropped**: AI Studio installs no `fetchResponse` (`src/adapters/google.ts:384`), |
| 5 | +> so the adapter can never observe the 404; the only hosts are the core pre-stream |
| 6 | +> recovery loop or the mid-stream terminal guard, and the latter would splice two |
| 7 | +> upstream turns into one client stream. |
| 8 | +
|
| 9 | +## Defect |
| 10 | + |
| 11 | +`GEMINI_DIRECT_WIRE_RENAMES` (src/adapters/google.ts:58-61) unconditionally |
| 12 | +rewrites `gemini-3.7-flash` -> `gemini-3.7-flash-tiered` for every direct Google |
| 13 | +deployment. Two live captures disagree: |
| 14 | + |
| 15 | +- `a70bb78d4` (2026-08-14): bare 404s, `-tiered` 200s. |
| 16 | +- #1894 (2026-08-16): bare 200s, `-tiered` 404s, `models.list` has no `-tiered` row. |
| 17 | + |
| 18 | +Neither reporter is wrong; the spelling differs per account/rollout. A static |
| 19 | +default therefore breaks one population whichever value it takes. |
| 20 | + |
| 21 | +## Decision (rev 2) |
| 22 | + |
| 23 | +**Land #1739 only.** It is the whole of WP1's production change. No new |
| 24 | +mechanism ships in this work-phase. |
| 25 | + |
| 26 | +#1739 real state: head `e1c7ec85e`, OPEN, `MERGEABLE/BLOCKED`, |
| 27 | +`reviewDecision=CHANGES_REQUESTED`. Its diff is larger than rev 1 recorded: |
| 28 | + |
| 29 | +| #1739 change | Note | |
| 30 | +|---|---| |
| 31 | +| `resolveDirectGeminiWireModelId(modelId, applyRenames)` | the config gate | |
| 32 | +| new `googleMode === "vertex" ? parsed.modelId` branch | Vertex keeps requested identity | |
| 33 | +| `messagesToGeminiFormat(parsed, identityModelId)` signature change | **the open review finding** | |
| 34 | +| `identityModelId` split for CCA vs direct | stops the `-tiered` wire spelling leaking into the model identity line | |
| 35 | + |
| 36 | +The identity split is a real second bug fix — without it the system prompt tells |
| 37 | +the model it is `gemini-3.7-flash-tiered`. The open reviewer finding is that the |
| 38 | +fix is applied too broadly across Google modes; that must be resolved before |
| 39 | +landing, not merged as-is. |
| 40 | + |
| 41 | +## Deferred to its own work-phase: discovery-resolved spelling |
| 42 | + |
| 43 | +The durable fix is to stop guessing and read what the account advertises. |
| 44 | +`src/oauth/index.ts:811` already issues `/v1beta/models?pageSize=1000` per |
| 45 | +provider. A later work-phase can resolve the wire spelling from that listing, |
| 46 | +keyed on destination + credential identity exactly as |
| 47 | +`src/responses/reasoning-replay-cache.ts:65` does, with an explicit |
| 48 | +`directGeminiWireRenames` value always winning over any inferred spelling. |
| 49 | +That is a separate PABCD cycle, not a rider on #1739. |
| 50 | + |
| 51 | +## File change map (WP1 as executed) |
| 52 | + |
| 53 | +| File | Change | |
| 54 | +|------|--------| |
| 55 | +| `src/types.ts` | `directGeminiWireRenames?: boolean` (from #1739) | |
| 56 | +| `src/config.ts` | zod boolean + round-trip incl. explicit `false` (from #1739) | |
| 57 | +| `src/adapters/google.ts` | config gate, Vertex identity branch, `identityModelId` split (from #1739, review finding resolved) | |
| 58 | +| `tests/config.test.ts` | persisted `false` round-trip; non-boolean rejected (from #1739) | |
| 59 | +| `tests/google-adapter.test.ts` | default/true/false wire ids; CCA unaffected; identity line uses the base id (from #1739) | |
| 60 | +| `docs-site/.../providers.md` | document the setting (from #1739) | |
| 61 | + |
| 62 | +## Scope boundary |
| 63 | + |
| 64 | +IN: direct AI Studio wire id resolution and the identity string derived from it. |
| 65 | +OUT: any new retry/recovery mechanism; `src/server/responses/core.ts`; |
| 66 | +Antigravity/CCA resolution; picker/catalog/usage/price keys (all stay on the base id). |
| 67 | + |
| 68 | +## Accept criteria (with activation) |
| 69 | + |
| 70 | +1. Default (setting absent) sends the `-tiered` id. |
| 71 | + *Activation:* `buildRequest` on a default provider; assert the URL path. |
| 72 | +2. `directGeminiWireRenames: false` sends the bare id. |
| 73 | + *Activation:* adapter built with the flag false; assert the URL path. |
| 74 | +3. The system-instruction identity names the base id, never the `-tiered` spelling. |
| 75 | + *Activation:* parse the built body `systemInstruction.parts[0].text` and assert |
| 76 | + it contains `powered by the gemini-3.7-flash` and NOT `-tiered`. |
| 77 | +4. Cloud Code Assist request paths are unchanged by the flag. |
| 78 | + *Activation:* build with `googleMode: cloud-code-assist` and both flag values. |
| 79 | +5. Config round-trips an explicit `false`; a non-boolean is rejected to fallback. |
| 80 | + |
| 81 | +Verifier: `bun test tests/google-adapter.test.ts tests/config.test.ts tests/gemini-37-flash-migration.test.ts` |
| 82 | +— all three exist and read the change target. |
| 83 | + |
| 84 | +## Closure |
| 85 | + |
| 86 | +#1894 gets the `bug` label (it is a real regression, currently labeled |
| 87 | +`provider-compatibility,provider` only). It closes only once #1739 is on |
| 88 | +`origin/dev` with 1-5 green. Because the default still favors the `-tiered` |
| 89 | +population, the closing comment must tell the #1894 reporter to set |
| 90 | +`directGeminiWireRenames: false` — closing silently would leave them broken. |
0 commit comments