fix(agent-kit): provide full thread context to first-time participating roles #476

Merged
xiaoju merged 1 commits from fix/473-first-time-role-context into main 2026-05-24 16:00:17 +00:00
Owner

What

First-time participating roles (e.g. committer) now receive full thread history instead of just the last step output.

Why

When a role has never participated before, the continuation prompt only contained system prompt + last step output. The role had no idea what happened in earlier steps, causing hallucination — e.g. committer inventing parameter names that differ from the actual implementation (#473).

Changes

  • workflow-protocol/types.ts — add isFirstVisit to AgentContext
  • workflow-agent-kit/context.ts — add isFirstVisit detection helper
  • workflow-agent-kit/build-continuation-prompt.ts — detect first-time roles and include all steps meta + last 2-3 steps content (within quota)
  • workflow-agent-hermes/hermes.ts — pass isFirstVisit through to prompt builder
  • workflow-agent-kit/__tests__/context.test.ts — new test file for isFirstVisit
  • workflow-agent-kit/__tests__/build-continuation-prompt.test.ts — tests for first-time context enrichment
  • workflow-agent-hermes/__tests__/hermes-prompt.test.ts — updated tests
  • cli-workflow/commands/thread.ts — minor adjustment

Ref

Fixes #473

## What First-time participating roles (e.g. committer) now receive full thread history instead of just the last step output. ## Why When a role has never participated before, the continuation prompt only contained system prompt + last step output. The role had no idea what happened in earlier steps, causing hallucination — e.g. committer inventing parameter names that differ from the actual implementation (#473). ## Changes - `workflow-protocol/types.ts` — add `isFirstVisit` to `AgentContext` - `workflow-agent-kit/context.ts` — add `isFirstVisit` detection helper - `workflow-agent-kit/build-continuation-prompt.ts` — detect first-time roles and include all steps meta + last 2-3 steps content (within quota) - `workflow-agent-hermes/hermes.ts` — pass `isFirstVisit` through to prompt builder - `workflow-agent-kit/__tests__/context.test.ts` — new test file for isFirstVisit - `workflow-agent-kit/__tests__/build-continuation-prompt.test.ts` — tests for first-time context enrichment - `workflow-agent-hermes/__tests__/hermes-prompt.test.ts` — updated tests - `cli-workflow/commands/thread.ts` — minor adjustment ## Ref Fixes #473
xiaoju added 1 commit 2026-05-24 15:57:34 +00:00
When a role participates for the first time (e.g. committer), it previously
only received the system prompt + last step output, missing the full thread
history. This caused hallucination as the role had to guess what happened.

Changes:
- build-continuation-prompt.ts: detect first-time roles and include all
  steps' meta + content for last 2-3 steps (within quota)
- context.ts: add isFirstVisit detection helper
- types.ts: add isFirstVisit field to AgentContext
- hermes.ts: pass isFirstVisit through to prompt builder

Fixes #473
xiaoju merged commit c2c849df7e into main 2026-05-24 16:00:17 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#476