feat(orchestration): implement state-based loop governor with forced checkpoints, phase events, and robust tool signatures

This commit is contained in:
2026-06-10 11:55:17 -07:00
parent 4550df6c1a
commit 8eaa20106a

View File

@@ -964,9 +964,17 @@ export async function POST(request: Request) {
extraSystem += `\n\n[WARNING] You only have ${maxToolRounds - round} tool calls left before you are forcefully terminated. Stop exploring, make your final edits, and write your final response to the user NOW.`;
}
// Execute tool calls and add results. OpenAI-compatible APIs
const resp = await callVibnChat({
systemPrompt: systemPrompt + extraSystem,
messages,
tools: toolDefs,
temperature: 0.7,
includeThoughts: true,
});
// C-08: Force Checkpoint Before Mutation
// If the AI is trying to use mutating tools but hasn't emitted a checkpoint,
// intercept the tool calls, block them, and force it to state its plan.
// (Moved safely *after* callVibnChat so 'resp' is defined)
const requestedMutations = resp.toolCalls.filter((tc) =>
[
"fs_write",
@@ -1010,15 +1018,6 @@ export async function POST(request: Request) {
});
}
// Execute tool calls and add results. OpenAI-compatible APIs
const resp = await callVibnChat({
systemPrompt: systemPrompt + extraSystem,
messages,
tools: toolDefs,
temperature: 0.7,
includeThoughts: true,
});
if (resp.error) {
emit({ type: "error", error: resp.error });
safeClose();