fix: preserve primary detail hash across frontmatter retries #443

Merged
xiaomo merged 1 commits from fix/439-detail-merge-and-acp into main 2026-05-23 14:14:53 +00:00
Owner

What

Preserve the first run's detail hash (containing full tool-call turn history) when frontmatter retry loop triggers continuation calls.

Why

When the agent's first run output fails frontmatter extraction, the retry loop replaces agentResult entirely, causing the 1-turn continuation detail to overwrite the original multi-turn detail. This made planner steps appear as "1 turn" despite having 17-22 actual turns with tool calls.

Root Cause

In createAgent (run.ts), the retry loop:

  1. First run: 22 turns, 147s, tool calls — but output has preamble before frontmatter → extraction fails
  2. Continue call: asks agent to fix frontmatter → 1 turn, correct format
  3. agentResult replaced entirely → detailHash now points to the 1-turn continuation

Changes

  • packages/workflow-agent-kit/src/run.ts — capture primaryDetailHash from first run, always use it for persisted StepNode

Verification

Before fix: numTurns: 1, turns: 1
After fix: numTurns: 22, turns: 61

Ref

Fixes #439

小橘 🍊(NEKO Team)

## What Preserve the first run's detail hash (containing full tool-call turn history) when frontmatter retry loop triggers continuation calls. ## Why When the agent's first run output fails frontmatter extraction, the retry loop replaces `agentResult` entirely, causing the 1-turn continuation detail to overwrite the original multi-turn detail. This made planner steps appear as "1 turn" despite having 17-22 actual turns with tool calls. ## Root Cause In `createAgent` (run.ts), the retry loop: 1. First run: 22 turns, 147s, tool calls — but output has preamble before frontmatter → extraction fails 2. Continue call: asks agent to fix frontmatter → 1 turn, correct format 3. `agentResult` replaced entirely → `detailHash` now points to the 1-turn continuation ## Changes - `packages/workflow-agent-kit/src/run.ts` — capture `primaryDetailHash` from first run, always use it for persisted StepNode ## Verification Before fix: `numTurns: 1, turns: 1` After fix: `numTurns: 22, turns: 61` ## Ref Fixes #439 小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-05-23 14:03:45 +00:00
When the agent's first run output fails frontmatter extraction, the
retry loop (via options.continue) would replace agentResult entirely,
causing the 1-turn continuation detail to overwrite the original
multi-turn detail containing all tool-call history.

Now we capture primaryDetailHash from the first run and always use it
for the persisted StepNode, regardless of how many retries occur.

Fixes #439
xiaomo approved these changes 2026-05-23 14:14:52 +00:00
xiaomo left a comment
Owner

LGTM 简洁准确。

LGTM ✅ 简洁准确。
xiaomo merged commit d37fa1393a into main 2026-05-23 14:14:53 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#443