fix(agent): trim leading whitespace from agent output before frontmatter extraction
CI / test (pull_request) Successful in 1m32s

Fixes #567
This commit is contained in:
2026-05-28 00:39:44 +00:00
parent 080b37c2be
commit efed4dee03
+2
View File
@@ -151,6 +151,7 @@ export function createAgent(options: AgentOptions): () => Promise<void> {
const startedAtMs = Date.now(); const startedAtMs = Date.now();
let agentResult = await runWithMessage("agent run failed", () => options.run(ctx)); 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 // Preserve the primary detail from the first run — it contains the full
// tool-call turn history. Continuation retries only fix frontmatter // tool-call turn history. Continuation retries only fix frontmatter
@@ -169,6 +170,7 @@ export function createAgent(options: AgentOptions): () => Promise<void> {
agentResult = await runWithMessage("agent continue failed", () => agentResult = await runWithMessage("agent continue failed", () =>
options.continue(agentResult.sessionId, correctionMessage, ctx.meta.store), options.continue(agentResult.sessionId, correctionMessage, ctx.meta.store),
); );
agentResult.output = agentResult.output.trimStart();
extracted = await tryExtractOutput(agentResult.output, roleDef.frontmatter, ctx); extracted = await tryExtractOutput(agentResult.output, roleDef.frontmatter, ctx);
} }