fix: drain sdk follow-up turns (#219)

This commit is contained in:
Eyejoker
2026-06-03 17:58:24 +08:00
committed by GitHub
parent 879d16235f
commit 807828e0ce
7 changed files with 137 additions and 10 deletions

View File

@@ -852,4 +852,53 @@ describe('agent-runner Codex goals', () => {
| undefined;
expect(spawnEnv?.CODEX_GOALS).toBe('true');
});
it('marks SDK codex processes so queued IPC follow-ups drain after the active run', async () => {
const previousCodexGoals = process.env.CODEX_GOALS;
delete process.env.CODEX_GOALS;
const onProcess = vi.fn();
const codexGroup: RegisteredGroup = {
...testGroup,
agentType: 'codex',
};
try {
const resultPromise = runAgentProcess(
codexGroup,
{
...testInput,
roomRoleContext: {
serviceId: 'codex-main',
role: 'owner',
ownerServiceId: 'codex-main',
reviewerServiceId: 'claude',
failoverOwner: false,
},
},
onProcess,
async () => {},
{
CODEX_RUNTIME: 'sdk',
CODEX_RUNTIME_SDK_ROLES: 'owner',
},
);
fakeProc.emit('close', 0);
const result = await resultPromise;
expect(result.status).toBe('success');
expect(onProcess).toHaveBeenCalledWith(
fakeProc,
expect.any(String),
expect.any(String),
{ drainFollowUpsAfterRun: true },
);
} finally {
if (previousCodexGoals === undefined) {
delete process.env.CODEX_GOALS;
} else {
process.env.CODEX_GOALS = previousCodexGoals;
}
}
});
});