feat(protocol): add edge prompt to Transition + EvaluateResult (#402)

- Transition type gains prompt: string | null
- evaluate() returns EvaluateResult { role, prompt } instead of string
- normalizeGraph coerces prompt: undefined → null
- spawnAgent passes edge prompt via UWF_EDGE_PROMPT env
- AgentContext gains edgePrompt field

Refs #402
This commit is contained in:
2026-05-23 03:49:15 +00:00
parent d5d05334f5
commit 1a06e014f5
8 changed files with 33 additions and 9 deletions
@@ -133,6 +133,7 @@ export async function buildContext(threadId: ThreadId, role: string): Promise<Ag
}
const steps = await buildHistory(store, chain.stepsNewestFirst);
const edgePrompt = process.env.UWF_EDGE_PROMPT ?? null;
return {
threadId,
@@ -142,6 +143,7 @@ export async function buildContext(threadId: ThreadId, role: string): Promise<Ag
workflow,
store,
outputFormatInstruction: "",
edgePrompt,
};
}
@@ -178,6 +180,7 @@ export async function buildContextWithMeta(
}
const steps = await buildHistory(store, chain.stepsNewestFirst);
const edgePrompt = process.env.UWF_EDGE_PROMPT ?? null;
return {
threadId,
@@ -187,6 +190,7 @@ export async function buildContextWithMeta(
workflow,
store,
outputFormatInstruction: "",
edgePrompt,
meta: { storageRoot, store, schemas, headHash, chain },
};
}
+6
View File
@@ -12,6 +12,12 @@ export type AgentContext = ModeratorContext & {
* role's output schema. Populated by `createAgent` at run time.
*/
outputFormatInstruction: string;
/**
* Edge prompt from the graph transition that led to this role.
* null on first entry (use full role definition), non-null on re-entry
* (use as continuation instruction from moderator).
*/
edgePrompt: string | null;
};
export type AgentRunResult = {