Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(maker-core): keep nameless Codex yield cells on a shared ledger key

Dasha53f519dcbbb
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index 0b5ebd79d8..adc771d899 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -17471,6 +17471,67 @@ describe('CodexAgent yield continuation', () => {
await handle.close();
});
+ it('keeps a nameless yielded exec_command when a later nameless wait completes', async () => {
+ const agent = new CodexAgent(createDeps());
+ let turnSeq = 0;
+ const host = installFakeHost(agent, (method) => {
+ if (method === Method.TurnStart) {
+ turnSeq += 1;
+ return { turn: { id: `turn-${turnSeq}` } };
+ }
+ return undefined;
+ });
+ const handle = await agent.startSession({
+ sessionId: 'session-yield-nameless-function-call',
+ model: 'gpt-5.4',
+ workingDir: '/repo',
+ });
+ const handlers = host.getThreadHandlers();
+ if (!handlers?.itemCompleted || !handlers.turnCompleted) {
+ throw new Error('expected item and turn handlers');
+ }
+ const events = await collectYieldEvents(handle);
+ await handle.send({ type: 'user', content: 'run typecheck' });
+ handlers.itemCompleted({
+ threadId: 'start-thread-id',
+ turnId: 'turn-1',
+ item: {
+ type: 'function_call',
+ name: 'exec_command',
+ arguments: JSON.stringify({
+ cmd: 'pnpm --filter desktop run typecheck',
+ yield_time_ms: 10_000,
+ }),
+ content: [{ type: 'output_text', text: 'Script running with cell ID 229' }],
+ },
+ });
+ handlers.itemCompleted({
+ threadId: 'start-thread-id',
+ turnId: 'turn-1',
+ item: {
+ type: 'function_call',
+ name: 'wait',
+ arguments: JSON.stringify({ cell_id: '11', yield_time_ms: 1000 }),
+ content: [{ type: 'output_text', text: 'Script running with cell ID 11\nWall time 1.0 seconds\nOutput:\n' }],
+ },
+ });
+ handlers.turnCompleted({
+ threadId: 'start-thread-id',
+ turn: { id: 'turn-1', status: 'completed' },
+ });
+ await waitForExpectation(() => {
+ expect(events.some((event) => event.type === 'done' && event.turnContinuationId != null)).toBe(true);
+ });
+ await vi.waitFor(() => {
+ expect(yieldTurnStartCalls(host)).toHaveLength(1);
+ });
+ const [, params] = yieldTurnStartCalls(host)[0] as [string, {
+ input: Array<{ text?: string }>;
+ }];
+ expect(params.input[0]?.text).toContain('Wait for cell ID 229');
+ await handle.close();
+ });
+
it('does not mint a claim after wait settles the yielded cell in the same turn', async () => {
const agent = new CodexAgent(createDeps());
const host = installFakeHost(agent, (method) => {
diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.ts
index 8cfd290639..952f85cb2e 100644
--- a/packages/maker-core/src/agents/codex/index.ts
+++ b/packages/maker-core/src/agents/codex/index.ts
@@ -3150,6 +3150,14 @@ export class CodexAgent extends BaseAgent {
if (!claim.settled || claim.pendingBoundaryEvents > 0) return;
yieldContinuationClaims.delete(claim.id);
};
+ const yieldItemLedgerKey = (record: Record<string, unknown> | null): string => {
+ if (!record) return '';
+ for (const key of ['id', 'call_id', 'callId'] as const) {
+ const value = record[key];
+ if (typeof value === 'string' && value.trim()) return value;
+ }
+ return '';
+ };
const abortYieldContinuationSend = (): void => {
const pending = yieldContinuationAbort;
yieldContinuationAbort = null;
@@ -3185,15 +3193,16 @@ export class CodexAgent extends BaseAgent {
const record = item && typeof item === 'object' && !Array.isArray(item)
? item as Record<string, unknown>
: null;
- const itemId = typeof record?.id === 'string' && record.id
- ? record.id
- : '';
+ const itemId = yieldItemLedgerKey(record);
const cells = extractYieldedExecCellsFromCodexItem(item);
const existing = yieldedExecCellsByTurnId.get(turnId) ?? new Map<string, YieldedExecCell[]>();
if (cells.length === 0) {
- if (phase === 'completed') existing.delete(itemId);
- } else {
+ if (phase === 'completed' && itemId) existing.delete(itemId);
+ } else if (itemId) {
existing.set(itemId, cells);
+ } else {
+ const anonymous = existing.get('') ?? [];
+ existing.set('', dedupeCells([...anonymous, ...cells]));
}
if (existing.size === 0) yieldedExecCellsByTurnId.delete(turnId);
else yieldedExecCellsByTurnId.set(turnId, existing);