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,21 @@
|
||||
/**
|
||||
* Build a minimal prompt for retrying frontmatter output on a resumed session.
|
||||
*
|
||||
* Used when a previous run completed successfully but frontmatter validation
|
||||
* failed — the session already has full context, we just need the agent to
|
||||
* re-output correctly formatted frontmatter without redoing any work.
|
||||
*/
|
||||
export function buildFrontmatterRetryPrompt(outputFormatInstruction: string): string {
|
||||
const parts: string[] = [
|
||||
"Your previous run completed all work successfully, but the output format was incorrect.",
|
||||
"You do NOT need to redo any work — all changes are already in place.",
|
||||
"",
|
||||
];
|
||||
if (outputFormatInstruction !== "") {
|
||||
parts.push(outputFormatInstruction, "");
|
||||
}
|
||||
parts.push(
|
||||
"Please output ONLY the corrected YAML frontmatter block (--- delimited) followed by a brief summary of the work you completed.",
|
||||
);
|
||||
return parts.join("\n");
|
||||
}
|
||||
@@ -12,6 +12,7 @@ export {
|
||||
} from "./extract.js";
|
||||
export type { FrontmatterFastPathResult } from "./frontmatter.js";
|
||||
export { tryFrontmatterFastPath } from "./frontmatter.js";
|
||||
export { buildFrontmatterRetryPrompt } from "./frontmatter-retry-prompt.js";
|
||||
export { createAgent, parseArgv } from "./run.js";
|
||||
export { getCachedSessionId, getCachePath, setCachedSessionId } from "./session-cache.js";
|
||||
export { getConfigPath, getEnvPath, loadWorkflowConfig, resolveStorageRoot } from "./storage.js";
|
||||
|
||||
Reference in New Issue
Block a user