feat: builtin agent session resume via deterministic message reconstruction (#426)
- StepRecord adds edgePrompt field (backward compat: defaults to "") - StepNode CAS schema includes edgePrompt - writeStepNode persists ctx.edgePrompt - buildHistory exposes edgePrompt in StepContext - buildBuiltinMessages reconstructs multi-turn moderator↔agent conversation: system = role prompt + output format (stable prefix) per prior visit: user (edgePrompt + inter-step summary) + assistant (output) current: user (edgePrompt + recent summary) - Zero extra persistence — pure function of CAS chain - Stable prefix for LLM prompt cache hits - 10 builtin tests pass, all other package tests pass
This commit is contained in:
@@ -49,8 +49,20 @@ describe("buildHermesPrompt", () => {
|
||||
isFirstVisit: false,
|
||||
edgePrompt: "The reviewer rejected your work. Fix the issues.",
|
||||
steps: [
|
||||
{ role: "developer", output: { summary: "Initial fix" }, agent: "uwf-hermes" },
|
||||
{ role: "reviewer", output: { approved: false }, agent: "uwf-hermes" },
|
||||
{
|
||||
role: "developer",
|
||||
output: { summary: "Initial fix" },
|
||||
agent: "uwf-hermes",
|
||||
detail: "detail-1",
|
||||
edgePrompt: "Implement the fix.",
|
||||
},
|
||||
{
|
||||
role: "reviewer",
|
||||
output: { approved: false },
|
||||
agent: "uwf-hermes",
|
||||
detail: "detail-2",
|
||||
edgePrompt: "Review the code.",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -66,7 +78,15 @@ describe("buildHermesPrompt", () => {
|
||||
const result = buildHermesPrompt(
|
||||
makeCtx({
|
||||
isFirstVisit: true,
|
||||
steps: [{ role: "developer", output: { done: true }, agent: "uwf-hermes" }],
|
||||
steps: [
|
||||
{
|
||||
role: "developer",
|
||||
output: { done: true },
|
||||
agent: "uwf-hermes",
|
||||
detail: "detail-1",
|
||||
edgePrompt: "First attempt.",
|
||||
},
|
||||
],
|
||||
edgePrompt: "Retry with a fresh approach.",
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user