← Back to PRs

#9486: feat(heartbeat): support primary/fallbacks model config

by sauerdaniel open 2026-02-05 08:18 View on GitHub →
size: S
## Summary This PR adds support for defining primary and fallback models in the `heartbeat` configuration, bringing it to parity with the agent model configuration. ## Changes - Updated `AgentDefaultsConfig` and `HeartbeatSchema` to allow `model` to be either a string (legacy) or an object with `{ primary, fallbacks }`. - Updated `heartbeat-runner.ts` to synthesize a runtime configuration when a complex heartbeat model is used. This ensures that the heartbeat model becomes the effective default model for the run, enabling standard fallback mechanisms (`runWithModelFallback`) to work correctly without changes to the core agent runner. - **Fix:** Tightened `HeartbeatSchema.target` validation to explicitly allow "last" and "none" literals in addition to channel ID strings, addressing review feedback. ## Motivation Currently, the heartbeat model can only be a single string. If that model provider is down (e.g., `zai` or `openai`), the heartbeat fails entirely. This change allows users to define a cheaper/faster primary model (e.g., `gemini-2.5-flash-lite`) and reliable fallbacks (e.g., `gemini-2.5-flash`, `gpt-4o-mini`). ## AI Contribution - **AI-Assisted**: Yes - **Generated by**: OpenCode (Gemini 3 Pro) - **Testing**: - [x] Type check (`pnpm tsgo`) passed for modified files. - [x] Automated testing (verified configuration synthesis logic via unit test). ## Local Validation ```bash pnpm build && pnpm check && pnpm test ``` All tests pass. TypeScript compilation clean. Lint passes.

Most Similar PRs