feat(codex): refine tool activity display

This commit is contained in:
weishu
2026-07-24 09:39:22 +08:00
parent dd42263aaf
commit 74ad25ec57
28 changed files with 1591 additions and 85 deletions
+82
View File
@@ -64,6 +64,7 @@ const harness = vi.hoisted(() => ({
emitSecondParentSpawnStartWithoutEnd: false,
emitParentSendInputFailure: false,
emitParentResumeSuccess: false,
emitParentV2AgentTools: false,
emitRunningChildTurnBeforeSuppressedParent: false,
emitCompletedChildTurnBeforeSuppressedParent: false,
emitTurnAbortedOnInterrupt: false,
@@ -426,6 +427,48 @@ vi.mock('./codexAppServerClient', () => {
this.notificationHandler?.('thread/compacted', parentCompact);
}
if (harness.emitParentV2AgentTools) {
const v2Calls = [{
callId: 'v2-spawn',
name: 'spawn_agent',
input: { task_name: 'review', message: 'Review this' },
output: { task_name: '/root/review', nickname: 'Reviewer' }
}, {
callId: 'v2-wait',
name: 'wait_agent',
input: { timeout_ms: 10_000 },
output: { message: 'Wait timed out.', timed_out: true }
}];
for (const call of v2Calls) {
const started = {
threadId,
turnId,
item: {
type: 'function_call',
namespace: 'collaboration',
name: call.name,
arguments: JSON.stringify(call.input),
call_id: call.callId
}
};
harness.notifications.push({ method: 'rawResponseItem/completed', params: started });
this.notificationHandler?.('rawResponseItem/completed', started);
const completed = {
threadId,
turnId,
item: {
type: 'function_call_output',
call_id: call.callId,
output: JSON.stringify(call.output)
}
};
harness.notifications.push({ method: 'rawResponseItem/completed', params: completed });
this.notificationHandler?.('rawResponseItem/completed', completed);
}
}
if (harness.emitParentSpawnFailureWithoutAgentId || harness.emitParentSpawnStartWithoutEnd) {
const spawnStart = {
item: {
@@ -1105,6 +1148,7 @@ describe('codexRemoteLauncher', () => {
harness.emitSecondParentSpawnStartWithoutEnd = false;
harness.emitParentSendInputFailure = false;
harness.emitParentResumeSuccess = false;
harness.emitParentV2AgentTools = false;
harness.emitRunningChildTurnBeforeSuppressedParent = false;
harness.emitCompletedChildTurnBeforeSuppressedParent = false;
harness.emitTurnAbortedOnInterrupt = false;
@@ -2477,6 +2521,44 @@ describe('codexRemoteLauncher', () => {
}));
});
it('forwards shared MultiAgent V2 tools as direct tool cards', async () => {
harness.emitParentV2AgentTools = true;
const { session, codexMessages } = createSessionStub();
await codexRemoteLauncher(session as never);
expect(codexMessages).toContainEqual(expect.objectContaining({
type: 'tool-call',
name: 'spawn_agent',
callId: 'v2-spawn',
input: { task_name: 'review', message: 'Review this' }
}));
expect(codexMessages).toContainEqual(expect.objectContaining({
type: 'tool-call-result',
callId: 'v2-spawn',
output: '{"task_name":"/root/review","nickname":"Reviewer"}'
}));
expect(codexMessages).toContainEqual(expect.objectContaining({
type: 'tool-call',
name: 'wait_agent',
callId: 'v2-wait',
input: { timeout_ms: 10_000 }
}));
expect(codexMessages).toContainEqual(expect.objectContaining({
type: 'tool-call-result',
callId: 'v2-wait',
output: '{"message":"Wait timed out.","timed_out":true}'
}));
expect(codexMessages).not.toContainEqual(expect.objectContaining({
type: 'agent-run-start',
cardId: 'v2-spawn'
}));
expect(codexMessages).not.toContainEqual(expect.objectContaining({
type: 'agent-run-update',
agentId: 'spawn-error:v2-spawn'
}));
});
it('marks pending spawn_agent cards failed with the Codex router argument error from stderr', async () => {
harness.emitParentSpawnStartWithoutEnd = true;
harness.emitParentSpawnRouterStderrError = true;