Add AgentForkFn and AgentCleanupFn type aliases. Extend AgentOptions
with fork: AgentForkFn | null and cleanup: AgentCleanupFn | null
fields. Add getAskSessionId / setAskSessionId session-cache helpers
using <stepHash>:ask key shape (coexists with exec sessions in the
same per-agent cache file). All four adapters pass fork: null,
cleanup: null — real wiring lands in Phase 2b. Resolves#145.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When frontmatter validation fails, the step is never written to CAS, so
isFirstVisit remains true on the next run. Both agent-claude-code and
agent-hermes gated session cache lookup behind !isFirstVisit, which
caused them to start a fresh session (and a new worktree) instead of
resuming the one that already has all the work done.
Changes:
- Remove the isFirstVisit guard from both adapters so they always check
the session cache.
- When isFirstVisit + cache hit (frontmatter-only failure), send a
minimal correction prompt via buildFrontmatterRetryPrompt() instead
of re-sending the full initial prompt — the session already has full
context, we just need the agent to re-output correctly formatted
frontmatter.
- Add buildFrontmatterRetryPrompt to util-agent with tests.
Fixes#139
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