From cfaee4c0dcd87f9fc0d18dfc32a7e1a610dd71d7 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 26 Apr 2026 03:44:56 +0200 Subject: [PATCH] fix(coding-agent/modes): added checks to skip writing error messages to - Added checks to skip writing error messages to stderr when stopReason is 'error' or 'aborted', as these cases already handle error output separately. - This prevents duplicate error reporting in print mode when the assistant encounters terminal error conditions. --- packages/ai/CHANGELOG.md | 1 + packages/coding-agent/src/modes/print-mode.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 826fbb816..0e8aa14f6 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -12,6 +12,7 @@ ### Fixed +- Fixed Anthropic tool schemas that used tuple-style arrays by stripping unsupported `maxItems` and only preserving provider-supported `minItems` values - Fixed Anthropic and OpenRouter Anthropic tool calls that previously failed with `compiled grammar is too large` by retrying automatically without strict tool schemas and reusing non-strict mode for subsequent requests in the same provider session - Fixed parsing of JSON tool arguments containing raw control characters inside string values (such as embedded newlines) by escaping them before JSON parsing - Fixed `validateToolArguments` to accept stringified objects and arrays that include literal control characters inside string fields diff --git a/packages/coding-agent/src/modes/print-mode.ts b/packages/coding-agent/src/modes/print-mode.ts index 4c3282d60..ce693216b 100644 --- a/packages/coding-agent/src/modes/print-mode.ts +++ b/packages/coding-agent/src/modes/print-mode.ts @@ -161,7 +161,11 @@ export async function runPrintMode(session: AgentSession, options: PrintModeOpti } } - if (assistantMsg.errorMessage) { + if ( + assistantMsg.errorMessage && + assistantMsg.stopReason !== "error" && + assistantMsg.stopReason !== "aborted" + ) { process.stderr.write(`${sanitizeText(assistantMsg.errorMessage)}\n`); }