fix(pi): converge worker failures and thinking state

This commit is contained in:
2026-08-25 11:45:14 +08:00
parent 274187e3cf
commit 61817b161f
28 changed files with 2019 additions and 118 deletions

View File

@@ -160,7 +160,7 @@ describe('Pi subagent scheduler', () => {
it('aborts every unfinished child with the parent and leaves no permit or process lease', async () => {
const processBudget = new PiProcessBudget(8);
const stopped: string[] = [];
const stopped: Array<{ taskId: string; reason: string }> = [];
const scheduler = new PiSubagentScheduler({
processBudget,
openChild: async (input) => ({
@@ -173,7 +173,7 @@ describe('Pi subagent scheduler', () => {
});
return { summary: 'unreachable' };
},
async stop() { stopped.push(input.taskId); },
async stop(reason) { stopped.push({ taskId: input.taskId, reason }); },
}),
});
const controller = new AbortController();
@@ -186,6 +186,7 @@ describe('Pi subagent scheduler', () => {
const result = await flight;
expect(result.details.tasks.map(({ status }) => status)).toEqual(['aborted', 'aborted']);
expect(stopped).toHaveLength(2);
expect(stopped.map(({ reason }) => reason)).toEqual(['subagent_abort', 'subagent_abort']);
expect(processBudget.activeCount).toBe(0);
await scheduler.close();
});