fix: use canonical cron session detection for spawn note

This commit is contained in:
Ayaan Zaidi
2026-02-26 17:20:45 +05:30
committed by Ayaan Zaidi
parent 69590de276
commit 452a8c9db9
2 changed files with 13 additions and 7 deletions

View File

@@ -4,7 +4,11 @@ import { DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH } from "../config/agent-limits.js";
import { loadConfig } from "../config/config.js";
import { callGateway } from "../gateway/call.js";
import { getGlobalHookRunner } from "../plugins/hook-runner-global.js";
import { normalizeAgentId, parseAgentSessionKey } from "../routing/session-key.js";
import {
isCronSessionKey,
normalizeAgentId,
parseAgentSessionKey,
} from "../routing/session-key.js";
import { normalizeDeliveryContext } from "../utils/delivery-context.js";
import { resolveAgentConfig } from "./agent-scope.js";
import { AGENT_LANE_SUBAGENT } from "./lanes.js";
@@ -527,7 +531,7 @@ export async function spawnSubagentDirect(
// Check if we're in a cron isolated session - don't add "do not poll" note
// because cron sessions end immediately after the agent produces a response,
// so the agent needs to wait for subagent results to keep the turn alive.
const isCronSession = ctx.agentSessionKey?.includes(":cron:");
const isCronSession = isCronSessionKey(ctx.agentSessionKey);
const note =
spawnMode === "session"
? SUBAGENT_SPAWN_SESSION_ACCEPTED_NOTE