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:
@@ -624,12 +624,14 @@ function resolveAgentConfig(
|
||||
return agentConfig;
|
||||
}
|
||||
|
||||
function spawnAgent(agent: AgentConfig, threadId: ThreadId, role: string, edgePrompt: string | null): CasRef {
|
||||
function spawnAgent(
|
||||
agent: AgentConfig,
|
||||
threadId: ThreadId,
|
||||
role: string,
|
||||
edgePrompt: string,
|
||||
): CasRef {
|
||||
const argv = [...agent.args, threadId, role];
|
||||
const env = { ...process.env };
|
||||
if (edgePrompt !== null) {
|
||||
env.UWF_EDGE_PROMPT = edgePrompt;
|
||||
}
|
||||
const env = { ...process.env, UWF_EDGE_PROMPT: edgePrompt };
|
||||
let stdout: string;
|
||||
try {
|
||||
stdout = execFileSync(agent.command, argv, {
|
||||
|
||||
@@ -55,11 +55,16 @@ function isJsonSchema(value: unknown): value is JSONSchema {
|
||||
function normalizeGraph(graph: Record<string, Transition[]>): Record<string, Transition[]> {
|
||||
const result: Record<string, Transition[]> = {};
|
||||
for (const [node, transitions] of Object.entries(graph)) {
|
||||
result[node] = transitions.map((t) => ({
|
||||
role: t.role,
|
||||
condition: t.condition ?? null,
|
||||
prompt: t.prompt ?? null,
|
||||
}));
|
||||
result[node] = transitions.map((t) => {
|
||||
if (typeof t.prompt !== "string" || t.prompt.trim() === "") {
|
||||
fail(`graph[${node}] transition to "${t.role}": prompt is required (non-empty string)`);
|
||||
}
|
||||
return {
|
||||
role: t.role,
|
||||
condition: t.condition ?? null,
|
||||
prompt: t.prompt,
|
||||
};
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ function isTransition(value: unknown): boolean {
|
||||
const condition = value.condition;
|
||||
return (
|
||||
typeof value.role === "string" &&
|
||||
typeof value.prompt === "string" &&
|
||||
value.prompt.trim() !== "" &&
|
||||
(condition === null || condition === undefined || typeof condition === "string")
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user