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
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user