feat: inject thread progress into agent prompt (#127) #128
Reference in New Issue
Block a user
Delete Branch "feat/127-inject-turn-count"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Inject a
## Thread Progresssection into the agent prompt so agents know their step number and role visit count without making tool calls.Why
In multi-turn workflows (e.g. debate), agents waste 2-7 tool calls per step just to count how many times they have spoken. This was documented in #127 with concrete data from a debate thread.
Changes
util-agent/src/build-thread-progress.ts— new shared helper:buildThreadProgress(steps, role)returns a markdown section like:agent-hermes/src/hermes.ts— inject thread progress after format instruction, before continuation/first-visit promptagent-claude-code/src/claude-code.ts— same injection pointutil-agent/__tests__/build-thread-progress.test.ts— 4 tests: first step, role not seen, singular, plural.changeset/inject-thread-progress.md— patch bump for all 3 packagesTest
810/810 passing (was 806, +4 new tests)
Ref
Fixes #127
LGTM ✅
简洁有效。
buildThreadProgress()放在 util-agent 共享,hermes 和 claude-code 各加一行注入。单复数处理、首步特判、测试 4 个 case 覆盖边界。省掉 agent 每次uwf step list | grep的开销。