mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-26 04:25:46 +02:00
fix(agent): align subagent lifecycle with openclaw
This commit is contained in:
@@ -47,10 +47,9 @@ export function initSubagentRegistry(): void {
|
||||
resumedRuns.add(runId);
|
||||
handleRunCompletion(record);
|
||||
}
|
||||
}
|
||||
// If not ended, the child agent session is lost on restart —
|
||||
// mark as ended with unknown outcome
|
||||
else if (!record.startedAt) {
|
||||
} else {
|
||||
// If not ended, the child agent session is lost on restart —
|
||||
// mark as ended with unknown outcome
|
||||
record.endedAt = Date.now();
|
||||
record.outcome = { status: "unknown" };
|
||||
persist();
|
||||
@@ -246,6 +245,10 @@ function handleRunCompletion(record: SubagentRunRecord): void {
|
||||
|
||||
if (!announced) {
|
||||
console.warn(`[SubagentRegistry] Announce flow failed for run ${record.runId}`);
|
||||
// Allow retry on next restart if announce failed.
|
||||
record.cleanupHandled = false;
|
||||
persist();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle session cleanup
|
||||
|
||||
@@ -100,6 +100,10 @@ export function createSessionsSpawnTool(
|
||||
model,
|
||||
});
|
||||
|
||||
// Write the task to the child (non-blocking) before registering,
|
||||
// so waitForIdle() observes the queued work.
|
||||
childAgent.write(task);
|
||||
|
||||
// Register the run for lifecycle tracking
|
||||
registerSubagentRun({
|
||||
runId,
|
||||
@@ -111,9 +115,6 @@ export function createSessionsSpawnTool(
|
||||
timeoutSeconds,
|
||||
});
|
||||
|
||||
// Write the task to the child (non-blocking)
|
||||
childAgent.write(task);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user