fix(agent-teams): align spawn schema and harden inbox rollback behavior

This commit is contained in:
Nguyen Khac Trung Kien
2026-02-08 11:26:20 +07:00
committed by YeonGyu-Kim
parent fe05a1f254
commit 40f844fb85
5 changed files with 102 additions and 20 deletions
+16 -3
View File
@@ -246,6 +246,8 @@ export async function spawnTeammate(params: SpawnTeammateParams): Promise<TeamTe
updateTeamConfig(params.teamName, (current) => upsertTeammate(current, nextMember))
return nextMember
} catch (error) {
const originalError = error
if (launchedTaskID) {
await params.manager
.cancelTask(launchedTaskID, {
@@ -255,9 +257,20 @@ export async function spawnTeammate(params: SpawnTeammateParams): Promise<TeamTe
})
.catch(() => undefined)
}
updateTeamConfig(params.teamName, (current) => removeTeammate(current, params.name))
clearInbox(params.teamName, params.name)
throw error
try {
updateTeamConfig(params.teamName, (current) => removeTeammate(current, params.name))
} catch (cleanupError) {
void cleanupError
}
try {
clearInbox(params.teamName, params.name)
} catch (cleanupError) {
void cleanupError
}
throw originalError
}
}