Skip to content

Commit c26346c

Browse files
committed
fix: address agent pipeline process failure when no tools are used
1. presenter.ts: Stop echoing task goals when cleanOutput() strips everything and no files were changed; properly delegate to presentFailure(). 2. repairLoop.ts: If QC flags TOOL_MISSING, inject a strong directive in the repair task telling the agent it MUST call tools. 3. ReactAgentAdapter.ts: Relax the isSubstantive filter to not discard multi-paragraph text that starts with a thinking opener.
1 parent fa811c3 commit c26346c

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

apps/desktop/src/agents/ReactAgentAdapter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,14 @@ export class ReactAgentAdapter implements AgentAdapter {
595595
// would surface internal monologue to the user if the loop later exits
596596
// at max_iterations.
597597
const extractedText = stripThoughtBlocks(cleanedOutput);
598-
const isSubstantive = extractedText.trim().length > 0
599-
&& !/^(Good|OK|Alright|Let me|I('ll| will| need| want| should)|Now |First)/im.test(extractedText.trim());
598+
// Only reject short single-sentence thinking preambles. Multi-paragraph
599+
// text that starts with a thinking opener may contain real content after
600+
// the first sentence — don't discard it.
601+
const trimmed = extractedText.trim();
602+
const looksLikePureThinking = trimmed.length < 500
603+
&& !/\n/.test(trimmed)
604+
&& /^(Good|OK|Alright|Let me|I('ll| will| need| want| should)|Now |First)/im.test(trimmed);
605+
const isSubstantive = trimmed.length > 0 && !looksLikePureThinking;
600606
if (isSubstantive) {
601607
currentOutputText = extractedText;
602608
}

packages/benson-core/src/presenter.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,11 @@ function presentSuccess(result: ExecutionResult, task: TaskSpec): string {
249249
return `Done. Created or updated:\n\n${fileList}`;
250250
}
251251

252-
// Last resort — construct a concise confirmation from the task goals.
253-
const summary = task.goals.length === 1
254-
? task.goals[0]
255-
: task.goals.map((g, i) => `${i + 1}. ${g}`).join("\n");
256-
257-
return `Done. Here is what was completed:\n\n${summary}`;
252+
// Last resort — cleanOutput stripped everything and no files were changed.
253+
// This means the agent produced no useful work. Do NOT echo the task goals
254+
// back ("Done. Here is what was completed:") — that's deceptive. Instead
255+
// delegate to the failure presenter so the user gets an honest answer.
256+
return presentFailure(result, task);
258257
}
259258

260259
function presentWarn(result: ExecutionResult, task: TaskSpec): string {

packages/orca-core/src/repairLoop.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,22 @@ export async function handleRepairLoop(
7474
// Prefer the AHP-based targeted repair prompt (set by Pappy's verifyAHPPacket)
7575
// over the legacy generic repairTask string when available.
7676
const repairInstruction = ahpPacket?.repairPrompt ?? currentQC.repairTask!;
77+
78+
// ── Tool-missing escalation ─────────────────────────────────────────────
79+
// If QC flagged TOOL_MISSING, the agent ran but never called tools.
80+
// Inject a strong directive — the agent MUST use its available tools.
81+
const hasToolMissing = currentQC.issues.some(
82+
(i) => i.code === 'TOOL_MISSING' || /tool.*(missing|not.*call)/i.test(i.message ?? i.description ?? ''),
83+
);
84+
const toolNudge = hasToolMissing
85+
? `\n\nCRITICAL: The previous attempt completed WITHOUT calling any tools. ` +
86+
`You MUST use your available tools (read_file, write_file, list_directory, etc.) ` +
87+
`to actually perform the work. Do NOT just describe what you would do — ` +
88+
`call the tools and do it. Use <tool_call> blocks to invoke tools.`
89+
: '';
90+
7791
const repairSpec: OrcaTaskSpec = {
78-
originalUserMessage: `${repairInstruction}${roleHint}`,
92+
originalUserMessage: `${repairInstruction}${roleHint}${toolNudge}`,
7993
intent: "repair",
8094
goals: [
8195
...originalTask.goals,

0 commit comments

Comments
 (0)