Files
united-workforce/packages/util-agent/__tests__/frontmatter-retry-prompt.test.ts
T
xiaoju aaadab4445
CI / check (pull_request) Successful in 1m58s
fix: decouple session resume from isFirstVisit guard
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
2026-06-07 02:36:12 +00:00

24 lines
966 B
TypeScript

import { describe, expect, test } from "vitest";
import { buildFrontmatterRetryPrompt } from "../src/frontmatter-retry-prompt.js";
describe("buildFrontmatterRetryPrompt", () => {
test("includes correction instruction", () => {
const result = buildFrontmatterRetryPrompt("Use YAML frontmatter");
expect(result).toContain("previous run completed");
expect(result).toContain("do NOT need to redo any work");
expect(result).toContain("corrected YAML frontmatter");
});
test("includes outputFormatInstruction when provided", () => {
const instruction = "---\nstatus: $done | $review\nsummary: string\n---";
const result = buildFrontmatterRetryPrompt(instruction);
expect(result).toContain(instruction);
});
test("works with empty outputFormatInstruction", () => {
const result = buildFrontmatterRetryPrompt("");
expect(result).not.toContain("\n\n\n");
expect(result).toContain("corrected YAML frontmatter");
});
});