Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(agent): re-validate tool pairing after preflight compaction

Jiayuan Zhang99167b983701
diff --git a/packages/core/src/agent/runner.ts b/packages/core/src/agent/runner.ts
index 90f5d5bec0..8d9f0de816 100644
--- a/packages/core/src/agent/runner.ts
+++ b/packages/core/src/agent/runner.ts
@@ -215,6 +215,9 @@ export class Agent {
let result = sanitizeToolCallInputs(messages);
result = sanitizeToolUseResultPairing(result);
result = this.preflightCompact(result);
+ // Re-validate after compaction — compaction can break tool_use/tool_result
+ // pairing by dropping assistant messages while keeping their tool_results
+ result = sanitizeToolUseResultPairing(result);
return result;
},
});