feat: inject thread progress into agent prompt (#127) #128

Merged
xiaomo merged 1 commits from feat/127-inject-turn-count into main 2026-06-06 00:53:11 +00:00
Owner

What

Inject a ## Thread Progress section 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:
    ## Thread Progress
    Thread step 6. You (proponent) have spoken 2 times before this turn.
    
  • agent-hermes/src/hermes.ts — inject thread progress after format instruction, before continuation/first-visit prompt
  • agent-claude-code/src/claude-code.ts — same injection point
  • util-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 packages

Test

810/810 passing (was 806, +4 new tests)

Ref

Fixes #127

## What Inject a `## Thread Progress` section 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: ``` ## Thread Progress Thread step 6. You (proponent) have spoken 2 times before this turn. ``` - `agent-hermes/src/hermes.ts` — inject thread progress after format instruction, before continuation/first-visit prompt - `agent-claude-code/src/claude-code.ts` — same injection point - `util-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 packages ## Test 810/810 passing (was 806, +4 new tests) ## Ref Fixes #127
xiaoju added 1 commit 2026-06-06 00:40:33 +00:00
feat: inject thread progress into agent prompt (#127)
CI / check (pull_request) Successful in 1m42s
5ed6f68e4b
Agents now receive a Thread Progress section showing current step number
and role visit count, eliminating tool calls to count turns.

- util-agent: new buildThreadProgress() helper
- agent-hermes: inject before continuation/first-visit prompt
- agent-claude-code: same injection point

Fixes #127
xiaomo approved these changes 2026-06-06 00:53:09 +00:00
xiaomo left a comment
Owner

LGTM

简洁有效。buildThreadProgress() 放在 util-agent 共享,hermes 和 claude-code 各加一行注入。单复数处理、首步特判、测试 4 个 case 覆盖边界。省掉 agent 每次 uwf step list | grep 的开销。

LGTM ✅ 简洁有效。`buildThreadProgress()` 放在 util-agent 共享,hermes 和 claude-code 各加一行注入。单复数处理、首步特判、测试 4 个 case 覆盖边界。省掉 agent 每次 `uwf step list | grep` 的开销。
xiaomo merged commit dd77b40f6c into main 2026-06-06 00:53:11 +00:00
xiaomo deleted branch feat/127-inject-turn-count 2026-06-06 00:53:11 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#128