fix: speed up brain inbox classification with gemini-cli#142
fix: speed up brain inbox classification with gemini-cli#142
Conversation
Gemini CLI was invoked without --prompt (forcing interactive-mode detection over /dev/null stdin) and with no model set, so the classify path fell back to gemini-2.5-pro — a thinking model. Switch to gemini-2.5-flash-lite by default, pass --prompt, and set --output-format text for clean parsing. Update sample provider config with model tiers so new installs pick up the fast model automatically.
There was a problem hiding this comment.
Pull request overview
Improves Brain’s CLI provider integration specifically for gemini-cli to avoid slow “thinking model” defaults and interactive-mode detection overhead during inbox classification.
Changes:
- Default
gemini-climodel togemini-2.5-flash-litewhen no model is configured. - Invoke
gemini-cliwith--promptand enforce--output-format textto keep calls non-interactive and faster. - Update sample provider config to include Gemini model tiers and a fast default model.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| server/services/brain.js | Adjusts gemini-cli invocation: adds model fallback, --output-format text, and passes prompt via --prompt. |
| data.sample/providers.json | Sets gemini-cli models and default/light/medium/heavy model fields so new installs use a fast model by default. |
| .changelog/NEXT.md | Documents the Brain gemini-cli performance fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ompt Addresses Copilot review on PR #142: - Strengthen the brain.js comment to call out that gemini-cli invocation in this path intentionally differs from runner.js/agentCliSpawning.js, which stream prompts via stdin. Brain runs headless with stdin ignored, so the prompt must go via --prompt and --output-format text to stay non-interactive. - Add spawn-mocked unit tests in brain.test.js pinning: prompt-via-flag, forced --output-format text, the gemini-2.5-flash-lite fallback when no model is set, explicit-model-override precedence, no duplicate --output-format when provider args already specify it, and the unchanged positional-arg behavior for non-gemini CLI providers.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot round-2 review on PR #142: - brain.js: the gemini-cli fast-model fallback now resolves to provider.lightModel first and only hard-codes gemini-2.5-flash-lite when nothing is configured. The sample providers.json already populates lightModel, so user-configured preferences win without code changes. - brain.test.js: drop the CLI test provider timeout from 1000ms to 50ms so the uncleared setTimeout in callAI() doesn't keep the event loop busy at the tail of the suite. Add coverage for the new lightModel path.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot round-3 review on PR #142: before this change callAI silently fell back to a concrete gemini-cli model, but runDailyDigest, runWeeklyReview, captureThought, and retryClassification persisted ai.modelId using the caller's original (possibly null) override. Cost and debug attribution could read "modelId: null" for a request that actually ran on gemini-2.5-flash-lite. - callAI now returns { content, model, providerId } so the resolved model is visible to every caller. - runDailyDigest, runWeeklyReview, and classifyInBackground now store the returned model/providerId in their ai metadata (inbox entry is patched after classification completes so the initial "intent" record is overwritten with what actually ran). - New test pins the digest path: with gemini-cli, no defaultModel, and no lightModel configured, ai.modelId persists as gemini-2.5-flash-lite, not null.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
geminifell back togemini-2.5-pro(a thinking model), and because--promptwas never passed the CLI also went through its interactive-mode-detection path over/dev/nullstdin.brain.js callAI()now sends gemini-cli prompts via--prompt, forces--output-format text, and defaults the model togemini-2.5-flash-lite(thinking disabled) when none is set.models/defaultModel/lightModel/mediumModel/heavyModelfor gemini-cli so new installs pick up the fast model automatically.Test plan
cd server && npm test— 2371 tests passdefaultProvider: gemini-cliand confirm classification completes in a few seconds instead of tens of seconds