From abc9dcfc5a29e5af1d189ed6bb907354ade99883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=A9=98?= Date: Thu, 28 May 2026 00:42:22 +0000 Subject: [PATCH] fix(agent): trim leading whitespace from agent output before frontmatter extraction (#570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 小橘 Co-committed-by: 小橘 --- packages/workflow-util-agent/src/run.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/workflow-util-agent/src/run.ts b/packages/workflow-util-agent/src/run.ts index b6d08f6..ecb139d 100644 --- a/packages/workflow-util-agent/src/run.ts +++ b/packages/workflow-util-agent/src/run.ts @@ -151,6 +151,7 @@ export function createAgent(options: AgentOptions): () => Promise { const startedAtMs = Date.now(); let agentResult = await runWithMessage("agent run failed", () => options.run(ctx)); + agentResult.output = agentResult.output.trimStart(); // Preserve the primary detail from the first run — it contains the full // tool-call turn history. Continuation retries only fix frontmatter @@ -169,6 +170,7 @@ export function createAgent(options: AgentOptions): () => Promise { agentResult = await runWithMessage("agent continue failed", () => options.continue(agentResult.sessionId, correctionMessage, ctx.meta.store), ); + agentResult.output = agentResult.output.trimStart(); extracted = await tryExtractOutput(agentResult.output, roleDef.frontmatter, ctx); }