fix: add missing Zod schema and type definitions for timeoutSeconds

- Zod schema: Add timeoutSeconds to HeartbeatSchema (src/config/zod-schema.agent-runtime.ts)
- TypeScript types: Add timeoutSeconds to heartbeat config with documentation (src/config/types.agent-defaults.ts)
- Runtime: Use conditional spread pattern for heartbeatModelOverride to avoid undefined in object (src/infra/heartbeat-runner.ts)
- Fix duplicate includeReasoning field in HeartbeatSchema

Addresses Greptile review feedback on PR #48568:
1. Missing Zod schema update — configs with timeoutSeconds would be rejected
2. Missing TypeScript type definition — compilation would fail
3. heartbeatModelOverride: undefined explicitly included when only timeout is set
This commit is contained in:
hope 2026-03-17 08:13:01 +08:00
parent 7a489dad18
commit 950ed293d3
3 changed files with 10 additions and 1 deletions

View File

@ -269,6 +269,14 @@ export type AgentDefaultsConfig = {
* Default: false (only the final heartbeat payload is delivered).
*/
includeReasoning?: boolean;
/**
* Max timeout in seconds for a heartbeat embedded run.
* Allows heartbeats to fail fast (e.g., 60s) when a model hangs,
* without affecting the global agents.defaults.timeoutSeconds (default 600s).
*
* Default: undefined (inherits agents.defaults.timeoutSeconds).
*/
timeoutSeconds?: number;
};
/** Max concurrent agent runs across all conversations. Default: 1 (sequential). */
maxConcurrent?: number;

View File

@ -35,6 +35,7 @@ export const HeartbeatSchema = z
suppressToolErrorWarnings: z.boolean().optional(),
lightContext: z.boolean().optional(),
isolatedSession: z.boolean().optional(),
timeoutSeconds: z.number().int().positive().optional(),
})
.strict()
.superRefine((val, ctx) => {

View File

@ -714,7 +714,7 @@ export async function runHeartbeatOnce(opts: {
heartbeatModelOverride || timeoutOverrideSeconds !== undefined
? {
isHeartbeat: true,
heartbeatModelOverride,
...(heartbeatModelOverride !== undefined && { heartbeatModelOverride }),
suppressToolErrorWarnings,
bootstrapContextMode,
...(timeoutOverrideSeconds !== undefined && { timeoutOverrideSeconds }),