fix(coding-agent): avoid pre-prompt compaction continue

This commit is contained in:
Michael Yu
2026-06-25 21:43:03 +08:00
parent 09f1059575
commit 73581ea995
2 changed files with 79 additions and 10 deletions
@@ -1075,17 +1075,11 @@ export class AgentSession {
throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
}
// Check if we need to compact before sending (catches aborted responses)
// Check if we need to compact before sending (catches aborted responses).
// The user's new prompt is sent below, so do not call agent.continue() here.
const lastAssistant = this._findLastAssistantMessage();
if (lastAssistant && (await this._checkCompaction(lastAssistant, false))) {
try {
await this.agent.continue();
while (await this._handlePostAgentRun()) {
await this.agent.continue();
}
} finally {
this._flushPendingBashMessages();
}
if (lastAssistant) {
await this._checkCompaction(lastAssistant, false);
}
// Build messages array (custom message if any, then user message)