Skip to content

Commit dadaaf6

Browse files
stainluclaude
andcommitted
fix(pool): use agent maxSubagentDepth for warm containers, fix event count assertion
Two fixes: - warmForAgent was minting parent tokens with remainingDepth=0, which caused warm containers for agents with callableAgents to fail delegation (call_agent got 403 max_subagent_depth_reached). Now uses agent.maxSubagentDepth so warm containers can delegate. - e2e event count assertion now counts only conversation events (user.message + agent.message) rather than total events, since our observability changes added session.model_change and session.thinking_level_change events to the stream. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f547ea4 commit dadaaf6

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/orchestrator/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class AgentRouter {
142142
// session ID in the labels (overwritten at claim time is a future
143143
// improvement) and a no-delegation parent token.
144144
const spawnOptions = this.buildSpawnOptions("__warm__", agent, {
145-
remainingSubagentDepth: 0,
145+
remainingSubagentDepth: agent.maxSubagentDepth,
146146
environmentId: null,
147147
} as Session);
148148
await this.pool.warmForAgent(agentId, spawnOptions);

test/e2e.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,16 @@ echo "[e2e] post-restart session OK (status=${RESTORED_STATUS}, output contains
227227

228228
echo "[e2e] post-restart: GET /v1/sessions/${SESSION_ID}/events"
229229
RESTORED_EVENTS=$(curl --silent --fail "${BASE_URL}/v1/sessions/${SESSION_ID}/events")
230-
RESTORED_EVENT_COUNT=$(echo "${RESTORED_EVENTS}" | jq -r '.count')
231-
if [[ "${RESTORED_EVENT_COUNT}" != "4" ]]; then
232-
echo "[e2e] FAIL: expected 4 events post-restart (2 user + 2 agent.message), got ${RESTORED_EVENT_COUNT}"
230+
# Count conversation events only (user.message + agent.message). Session
231+
# metadata events (model_change, thinking_level_change) vary per provider.
232+
CONVO_COUNT=$(echo "${RESTORED_EVENTS}" | jq '[.events[] | select(.type == "user.message" or .type == "agent.message")] | length')
233+
TOTAL_COUNT=$(echo "${RESTORED_EVENTS}" | jq -r '.count')
234+
if [[ "${CONVO_COUNT}" != "4" ]]; then
235+
echo "[e2e] FAIL: expected 4 conversation events post-restart (2 user + 2 agent.message), got ${CONVO_COUNT}"
233236
echo "${RESTORED_EVENTS}" | jq '.events | map({type, content: (.content | .[0:60])})'
234237
exit 1
235238
fi
236-
echo "[e2e] post-restart events OK (count=${RESTORED_EVENT_COUNT})"
239+
echo "[e2e] post-restart events OK (conversation=${CONVO_COUNT}, total=${TOTAL_COUNT})"
237240

238241
echo "[e2e] post-restart: GET /v1/agents/${AGENT_ID}"
239242
RESTORED_AGENT=$(curl --silent --fail "${BASE_URL}/v1/agents/${AGENT_ID}")

0 commit comments

Comments
 (0)