-
Notifications
You must be signed in to change notification settings - Fork 5
Headless polling loop exits prematurely (12-30s) for direct API models #16
Description
Description
When using direct API model names (google/gemini-2.5-pro, openai/gpt-4.1) in headless mode, the polling loop exits almost immediately after the model begins its first tool call (file read). The sidecar session is marked complete but no summary is produced.
Steps to Reproduce
- Configure direct API keys in
~/.config/sidecar/.env:GOOGLE_GENERATIVE_AI_API_KEY=... OPENAI_API_KEY=... - Launch headless sidecar with a direct API model:
sidecar start --model google/gemini-2.5-pro --agent Plan --no-ui --no-context --timeout 20 \ --prompt "Read and review _bmad-output/planning-artifacts/prd.md" - Observe logs:
[sidecar] 15s | 4 messages | Executing tool call... {"level":"error","msg":"Polling loop exited","completed":false,"pollCount":9,"stablePolls":4,"elapsed":18135}
Expected Behavior
Polling loop waits for the model to finish processing (up to the --timeout value).
Actual Behavior
Polling loop exits after ~4 "stable polls" (~12-18 seconds) even though the model is mid-tool-call. The stablePolls: 4 suggests there's a stability threshold that's too aggressive — the model is reading a large file (917 lines) and the polling loop interprets the wait as "nothing happening."
Affected Models
google/gemini-2.5-pro(direct Google API)openai/gpt-4.1(direct OpenAI API)- OpenRouter aliases (
gemini,gemini-pro) did NOT exhibit this — they either completed successfully or hung indefinitely (separate issue)
Workaround
None found. Increasing --timeout does not help since the polling loop exits on its own stability check, not the timeout.