Repository navigation
Enhance dev-lead and pr-review engines for Gemini 3.5 models #382
Description
Summary
Upgrade the dev-lead and pr-review agent engines to support the new Gemini 3.5 model family (starting with gemini-3.5-flash) with safe rollout controls, capability-aware routing, and observability.
Why
Current implementation appears optimized around older Gemini variants. Gemini 3.5 introduces improved function-calling/tool-use behavior and updated SDK/API patterns that are directly relevant to both dev-lead (planning/orchestration) and pr-review (code reasoning/review quality).
This enhancement should reduce drift from current Google model best practices and allow us to tune for latency/quality/cost across both agents.
Research notes (official docs)
- Gemini docs now include current Gemini 3.5 pages and examples using model IDs like
gemini-3.5-flash. - Function-calling docs show Gemini 3.5 usage and emphasize explicit function declarations + structured call handling.
- Migration docs emphasize moving to Google GenAI SDK (
google-genai/@google/genai) and centralized client usage. - Model listings can lag or vary by page/locale, so we should avoid hard-coding assumptions and rely on capability/config checks at runtime.
Proposed approach
-
Configurable model registry
- Add per-agent model config (default + fallback + override), e.g.:
DEV_LEAD_MODEL=gemini-3.5-flashPR_REVIEW_MODEL=gemini-3.5-flash
- Keep safe fallback (e.g., existing 2.5 model) behind feature flags.
- Add per-agent model config (default + fallback + override), e.g.:
-
Capability-aware selection
- Route by task type and required capabilities (tool-calling, long-context, structured output).
- Fail closed with explicit errors when requested model/capability is unavailable (no silent downgrade unless fallback explicitly enabled).
-
Provider client modernization
- If still on legacy SDKs, migrate provider adapter to Google GenAI SDK patterns.
- Normalize request/response schema for function calls across both agents.
-
Prompt/runtime compatibility updates
- Validate tool-call schema strictness for Gemini 3.5.
- Ensure pr-review output contracts (JSON/markdown sections) remain deterministic.
-
Observability + rollout
- Add per-agent metrics/log tags: model ID, token usage, latency, tool-call count, error class.
- Ship behind staged rollout flag:
- Phase 1: opt-in (internal)
- Phase 2: default-on for one agent
- Phase 3: default-on for both agents
Deliverables
- Engine config support for Gemini 3.5 model IDs per agent.
- Provider adapter updates for SDK/API compatibility.
- Routing + fallback logic with explicit error handling.
- Regression tests for:
- dev-lead planning/tool orchestration
- pr-review multi-file review quality and output schema
- Rollout docs + env var examples.
Acceptance criteria
- Both agents can be configured to run on
gemini-3.5-flashin non-prod and prod. - No schema regressions in pr-review output contract.
- Tool-calling reliability is at least baseline (or better) vs current model.
- Latency/cost deltas are measured and documented.
- Fallback behavior is explicit, tested, and controllable.
Risks / open questions
- Exact availability of specific Gemini 3.5 variants across environments/regions.
- Potential function-calling behavior differences that may require stricter tool schema validation.
- Whether to split routing defaults by agent objective (quality-first pr-review vs speed-first dev-lead).
Activity
don-petry commentedon May 24, 2026
Dev-Lead Implementation Plan
Issue: #382 — Enhance dev-lead and pr-review engines for Gemini 3.5 models
Scope
Add per-tier Gemini model configurability and a safe-rollout fallback chain to
scripts/engine.sh, mirroring the existing Claude chain pattern, so dev-lead and pr-review workflows can opt into Gemini 3.5 model IDs (e.g.gemini-3.5-flash) via env vars without code changes — with fail-closed behavior when every model in the chain is rate-limited.Implementation Checklist
scripts/engine.sh: honorGEMINI_{TRIAGE,DEEP,AUDIT,ACTION,SINGLE}_MODELenv-var overrides in thegeminibranch ofset_engine_configscripts/engine.sh: introduceGEMINI_{TRIAGE,DEEP,AUDIT,ACTION,SINGLE}_MODEL_CHAINenv vars (default: empty) for staged rolloutscripts/engine.sh: add_gemini_chain_invokehelper parallel to_claude_chain_invoke— walks comma-separated chain, rate-limited attempts fall through, non-rate-limit failures propagate immediately, all-rate-limited returns 2scripts/engine.sh: wire_gemini_chain_invokeinto thegeminibranches ofrun_triage,run_agentic, andrun_writeronly when a chain is configured; otherwise current single-model behavior is preservedscripts/engine.sh: preserve explicitmodelargument pinning (chain expansion only when caller used the tier default — same contract as Claude)docs/dev-lead/spec.mdordocs/pr-review-agent/setup.md: short rollout-vars section withGEMINI_*_MODEL/GEMINI_*_MODEL_CHAINexamplesTests to Write
tests/dev-lead/unit/test_engine_chain.bats: gemini chain — first model succeeds (no fallback attempted)GEMINI_*_MODELoverride is honored when no chain is setCLAUDE_ACTION_MODEL_CHAIN/GEMINI_ACTION_MODEL_CHAINsymmetrically per engineTest Command
bats tests/dev-lead/unit/test_engine_chain.batsfor the focused unit tests;bats tests/dev-lead/unit/ tests/*.batsfor the full bats suite, plusshellcheck --severity=warning -x scripts/engine.shfor lint.don-petry commentedon May 24, 2026
Dev-Lead: Implementation Complete
Plan Execution
scripts/engine.sh: per-tierGEMINI_{TRIAGE,DEEP,AUDIT,ACTION,SINGLE}_MODELenv overrides honored inset_engine_configscripts/engine.sh:GEMINI_{TRIAGE,DEEP,AUDIT,ACTION,SINGLE}_MODEL_CHAINenv vars (empty default → preserves single-model behavior)scripts/engine.sh:_gemini_chain_invokehelper mirrors_claude_chain_invoke(rate-limit → walk chain; non-rate-limit → propagate; all RL → exit 2; empty chain → config error rc=1)scripts/engine.sh: chain wired intorun_triage,run_agentic,run_writerscripts/engine.sh: explicit caller-pinned model arg bypasses chain expansion (same contract as Claude)scripts/engine.sh: token-record logging records the model that actually produced output (chain-aware)tests/dev-lead/fixtures/engines/stub-gemini: extended to supportSTUB_ENGINE_EXIT_BY_MODEL/STUB_ENGINE_RESPONSE_BY_MODEL/STUB_ENGINE_RECORD_MODELS(parity with stub-claude)docs/engine-model-rollout.md: phased rollout doc with phase-1/2/3 env var examplesTest Results
New tests (
tests/dev-lead/unit/test_engine_gemini_chain.bats):Full bats suite (
tests/dev-lead/unit/+ top-leveltests/*.bats):Lint:
Concurrency integration test: PASS.
Pre-existing failures unrelated to this change:
tests/test-validate-engines.shreports 2 failures on this branch before my changes (verified bygit stash). Not in scope for #382.Files Changed
scripts/engine.sh: gemini per-tier model overrides +_gemini_chain_invoke+ chain wiring in triage/agentic/writer + chain-aware token recording; clearGEMINI_*_MODEL_CHAINin non-gemini branches to prevent bleedtests/dev-lead/fixtures/engines/stub-gemini: per-model exit/response/recording (parity with stub-claude)tests/dev-lead/unit/test_engine_chain.bats: updated one assertion (! grep -q "^claude-"instead of empty-file check) since stub-gemini now records tootests/dev-lead/unit/test_engine_gemini_chain.bats: 19 new tests covering env overrides, chain control flow, writer/agentic/triage wiring, and claude-isolation guarddocs/engine-model-rollout.md: rollout doc with phase-1/2/3 env var examples and fail-closed contractNotes
run_duck(cross-engine adversarial review) is intentionally not chain-wired — the duck is a one-shot adversarial pass and shouldn't itself stage rollout decisions across model variants._gemini_chain_invokehelper duplicates_claude_chain_invokerather than factoring a shared helper. Refactoring is out of scope for Enhance dev-lead and pr-review engines for Gemini 3.5 models #382; the two helpers can be consolidated in a follow-up.gemini-3.5-flashis not hard-coded anywhere — the implementation is model-ID-agnostic, so any future Gemini model ID works via the same env vars without code changes (the "no hard-coded assumptions, rely on config" guidance in the issue's research notes).Merge origin/main into dev-lead/issue-382-20260524-0133
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
don-petry commentedon Jun 8, 2026
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
don-petry commentedon Jun 8, 2026
@dev-lead the prior implementation (PR #383) has been closed — it went stale and its rebase regressed functionality that has since landed in
main. Please re-implement this issue fresh from currentmain.Critical constraints (these caused the regressions in #383):
mainand verify your changes are additive — do not remove or rewrite existing behavior inscripts/engine.sh,scripts/review-one-pr.sh, or.github/workflows/pr-review.yml.workflow_callfor reusable callers; the PR-diff prefetch before triage; event-driven PR-review triggers; check-run dedup and the self-referential CI filter (lib/ci-status.sh, pr-review: mention-triggered runs silently lost to ci-pending skip (self-referential check runs) #469); the advisory-bot review gate (feat: implement advisory bot review gate in pr-review agent #458); the cycle-cap logic (lib/review-cycle.sh, pr-review: cycle cap counts approvals, ignores human re-requests, and escalation is unrecoverable #467); and the worktree collision-prevention inlib/pr-worktree.sh(fix(dev-lead): release stale PR-branch worktrees before checkout (#470) #494).shellcheck --severity=warning -xand the bats suites before opening the PR; open a NEW PR off a fresh branch.10 remaining items
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…
feat: implement issue #382 — Enhance dev-lead and pr-review engines f…