The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(code): read-only commands answer the question instead of counting tools
purplec64379b86c4b
diff --git a/src/hooks/__tests__/useCodex-fallback-answer.test.ts b/src/hooks/__tests__/useCodex-fallback-answer.test.tsindex e087197a..55d3a957 100644--- a/src/hooks/__tests__/useCodex-fallback-answer.test.ts+++ b/src/hooks/__tests__/useCodex-fallback-answer.test.ts@@ -25,7 +25,7 @@ interface MockBlock {toolCall?: { toolName: string; status: string }}-function buildFallbackAnswer(blocks: MockBlock[]): string {+function buildFallbackAnswer(blocks: MockBlock[], readOnlyTurn = false): string {const completed = blocks.filter(b => b.phase === 'tool_call' && b.toolCall?.status === 'completed')const failed = blocks.filter(b => b.phase === 'tool_call' && b.toolCall?.status === 'failed')const writes = completed.filter(b => b.toolCall?.toolName === 'file_write')@@ -46,6 +46,9 @@ function buildFallbackAnswer(blocks: MockBlock[]): string {if (failed.length > 0) {return `Partially done: ${parts.join(', ')}. Some steps failed — see the errors above; the result may be incomplete.`}+ if (readOnlyTurn) {+ return `I looked (${parts.join(', ') || 'no steps recorded'}) but the model ended without writing the answer. Send the command again, or switch to a stronger model for this one.`+ }return parts.length > 0 ? `Done: ${parts.join(', ')}.` : 'Done.'}@@ -163,6 +166,30 @@ describe('Codex fallback final answer', () => {})// ── Drift detection ─────────────────────────────────────────────────────+describe('read-only commands do not get an operations count as their answer', () => {+ // Live /find on the ship exe, 2026-07-25: gpt-oss searched twice, wrote no+ // text, and the user got "Done: 2 other operation(s) completed." A read-only+ // command was asked a QUESTION — a tool tally dressed up as success is worse+ // than admitting the answer never arrived.+ it('says the answer is missing instead of claiming a clean finish', () => {+ const blocks: MockBlock[] = [+ { phase: 'tool_call', toolCall: { toolName: 'file_search', status: 'completed' } },+ { phase: 'tool_call', toolCall: { toolName: 'file_search', status: 'completed' } },+ ]+ const answer = buildFallbackAnswer(blocks, true)+ expect(answer).not.toMatch(/^Done:/)+ expect(answer).toContain('ended without writing the answer')+ expect(answer).toContain('2 other operation(s) completed')+ })++ it('leaves the normal build-task summary alone', () => {+ const blocks: MockBlock[] = [+ { phase: 'tool_call', toolCall: { toolName: 'file_write', status: 'completed' } },+ ]+ expect(buildFallbackAnswer(blocks, false)).toBe('Done: 1 file(s) written.')+ })+})+describe('fallback answer drift detection', () => {it('useCodex.ts contains the honest fallback summary builder', () => {const __filename = fileURLToPath(import.meta.url)@@ -178,5 +205,12 @@ describe('fallback answer drift detection', () => {expect(src).toContain('Partially done:')expect(src).toContain("couldn't complete the task")expect(src).not.toContain('Task completed:')+ // The read-only branch must stay: a /find that produced no text has to say+ // so rather than reporting an operations count as a clean finish.+ expect(src).toContain('ended without writing the answer')+ // And the nudge must ask a read-only turn for the ANSWER, not another tool+ // call — demanding "the NEXT step as an actual tool call" is what burned the+ // budget and produced the count in the first place.+ expect(src).toContain('You have read enough. Write the answer now')})})diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex 8171f482..b4452ad1 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -1069,8 +1069,14 @@ export function useCodex() {void diagLog('continue-nudge', { iter: i, remaining: continueNudgesRemaining, turnContentLen: turnContent.length })messages.push({role: 'user',- content:- 'Continue working autonomously until the task is fully done. Do NOT narrate what you are about to do, and do NOT ask me for paths or details you can discover yourself — use file_list / file_search / file_read to find them. Emit the NEXT step as an actual tool call right now. Only stop once everything is finished and verified.',+ // A read-only command's deliverable IS the text. Demanding "the+ // NEXT step as an actual tool call" there sent the model back for+ // more searching until the budget ran out, and the user got+ // "Done: 2 other operation(s) completed." instead of the answer+ // they asked for (live /find on the ship exe, 2026-07-25).+ content: readOnlyTurn+ ? 'You have read enough. Write the answer now, in text, using what you found. Do not call any more tools and do not ask me for details you can look up. If something genuinely could not be determined, say which part and why.'+ : 'Continue working autonomously until the task is fully done. Do NOT narrate what you are about to do, and do NOT ask me for paths or details you can discover yourself — use file_list / file_search / file_read to find them. Emit the NEXT step as an actual tool call right now. Only stop once everything is finished and verified.',})continue}@@ -1557,6 +1563,11 @@ export function useCodex() {: `I stopped without completing the task, the model ended its turn without doing any work. Try rephrasing the instruction, or turn Think off and resend.`} else if (failed.length > 0) {fullContent = `Partially done: ${parts.join(', ')}. Some steps failed, see the errors above; the result may be incomplete.`+ } else if (readOnlyTurn) {+ // An operations count is not an answer. A read-only command was asked+ // a question, so say plainly that the question went unanswered rather+ // than dressing up a tool tally as success.+ fullContent = `I looked (${parts.join(', ') || 'no steps recorded'}) but the model ended without writing the answer. Send the command again, or switch to a stronger model for this one.`} else {fullContent = parts.length > 0 ? `Done: ${parts.join(', ')}.` : 'Done.'}