feat: make edge prompt required (Phase 1)

- Transition.prompt: string | null → string
- EvaluateResult.prompt: string | null → string
- AgentContext.edgePrompt: string | null → string
- CLI YAML validation rejects missing prompt
- All tests updated

Phase 2 will replace edgePrompt === null checks with findLastRoleIndex.

Refs #405, #406, #404
This commit is contained in:
2026-05-23 04:28:47 +00:00
parent b9258f84a5
commit 3d6399c0e3
16 changed files with 189 additions and 69 deletions
+10 -2
View File
@@ -21,6 +21,14 @@ function fail(message: string): never {
throw new Error(message);
}
function readEdgePrompt(): string {
const value = process.env.UWF_EDGE_PROMPT;
if (value === undefined || value === "") {
fail("UWF_EDGE_PROMPT environment variable is required");
}
return value;
}
function walkChain(store: Store, schemas: AgentStore["schemas"], headHash: CasRef): ChainState {
const headNode = store.get(headHash);
if (headNode === null) {
@@ -133,7 +141,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;
const edgePrompt = readEdgePrompt();
return {
threadId,
@@ -180,7 +188,7 @@ export async function buildContextWithMeta(
}
const steps = await buildHistory(store, chain.stepsNewestFirst);
const edgePrompt = process.env.UWF_EDGE_PROMPT ?? null;
const edgePrompt = readEdgePrompt();
return {
threadId,
+3 -4
View File
@@ -13,11 +13,10 @@ export type AgentContext = ModeratorContext & {
*/
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).
* Edge prompt from the graph transition that led to this role (UWF_EDGE_PROMPT).
* Phase 2 will use visit history to choose full role definition vs continuation.
*/
edgePrompt: string | null;
edgePrompt: string;
};
export type AgentRunResult = {