Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions codex-cli/src/utils/agent/agent-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ export class AgentLoop {
return;
}

// Reset the current stream to allow new requests
this.currentStream = null;
log(
`AgentLoop.cancel() invoked – currentStream=${Boolean(
this.currentStream,
Expand All @@ -132,6 +130,9 @@ export class AgentLoop {
this.currentStream as { controller?: { abort?: () => void } } | null
)?.controller?.abort?.();

// Reset the current stream to allow new requests
this.currentStream = null;

this.canceled = true;

// Abort any in-progress tool calls
Expand Down Expand Up @@ -859,13 +860,16 @@ export class AgentLoop {
this.onItem(item);
}
}
// guarading clear
// because we may still enter this after abort
this.pendingAborts.clear();
}

// At this point the turn finished without the user invoking
// `cancel()`. Any outstanding function‑calls must therefore have been
// satisfied, so we can safely clear the set that tracks pending aborts
// to avoid emitting duplicate synthetic outputs in subsequent runs.
this.pendingAborts.clear();
// this.pendingAborts.clear();
// Now emit system messages recording the per‑turn *and* cumulative
// thinking times so UIs and tests can surface/verify them.
// const thinkingEnd = Date.now();
Expand Down