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
feat(commands): /loop is an interval, not a deadline
purpleeb2f50ead1d2
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsxindex f1082c22..f747e0d4 100644--- a/src/components/chat/CodexView.tsx+++ b/src/components/chat/CodexView.tsx@@ -54,6 +54,9 @@ function stripChannelTags(text: string): string {// the PROVIDER's parser drops the `<t`, so a pattern anchored on `<`// cannot see the remainder. Line-anchored so prose is never touched.t = t.replace(/^[ \t]*<?[|/]*t?ool_(?:call|calls|response|result)s?[|/]*>[ \t]*$/gim, '')+ // 1c) The /loop control markers. They are protocol between the driver and+ // the model, not something the user needs to read.+ t = t.replace(/^[ \t]*LOOP_(?:DONE|CONTINUE)[ \t]*$/gm, '')// 2) The autonomous-continue NUDGE, if a weak model parrots it back as its// own answer (qwen2.5-coder:7b did this verbatim). It is OUR fixed// instruction from useCodex — strip from its opening clause ("…continuediff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex 0aca6edc..12cec8e3 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -19,7 +19,10 @@ import { setActiveChatId, clearActiveChatId, chatWorkspaceSlug, setActiveWorkspaimport { resolveWorkspace } from '../api/agents/workspace-resolve'import { useAgentModeStore } from '../stores/agentModeStore'import { loadLurules, renderRulesSection, type RulesReader } from '../lib/lurules'-import { parseAgentCommand, parseLoopBudget, formatDuration } from '../lib/agent-commands'+import {+ parseAgentCommand, parseLoopSpec, buildLoopRecheck, formatDuration,+ MAX_LOOP_PASSES, MAX_LOOP_TOTAL_MS, LOOP_DONE_MARKER,+} from '../lib/agent-commands'import { useGenerationStore } from '../stores/generationStore'import { backendCall, isOllamaLocal } from '../api/backend'import { planWithArchitect, renderArchitectPlanSection } from '../api/agents/architect'@@ -193,8 +196,20 @@ export function useCodex() {const [isRunning, setIsRunning] = useState(false)const abortRef = useRef<AbortController | null>(null)const runningRef = useRef(false)-- const sendInstruction = useCallback(async (rawInstruction: string, opts?: { displayContent?: string }) => {+ /** True once the user pressed stop, so the /loop driver does not start+ * another pass on the run they just killed. Cleared when a new run starts. */+ const userStoppedRef = useRef(false)+ /** The pending next /loop pass, so stop can cancel it mid-interval. */+ const loopTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)++ const sendInstruction = useCallback(async (+ rawInstruction: string,+ opts?: {+ displayContent?: string+ /** Set by the /loop driver when this run is pass 2 or later. */+ loop?: { pass: number; intervalMs: number; task: string; startedAt: number }+ },+ ) => {const { activeModel } = useModelStore.getState()if (!activeModel) return@@ -212,11 +227,19 @@ export function useCodex() {// this turn, so /review and /security physically cannot rewrite the files// they were asked to look at.const readOnlyTurn = slash?.command.readOnly === true- // `/loop [20m] …` — the budget is enforced by the loop below, not just- // stated in the prompt. A model told "you have 20 minutes" and left to- // police itself will happily run for an hour.- const loopBudgetMs = slash?.command.name === 'loop' ? parseLoopBudget(slash.args).budgetMs : null- const loopDeadline = loopBudgetMs ? Date.now() + loopBudgetMs : null+ // A brand-new instruction clears a previous stop; a /loop pass inherits it.+ if (!opts?.loop) userStoppedRef.current = false+ // `/loop [30s] …` — the interval is the PAUSE BETWEEN PASSES, and the+ // driver at the end of this function is what actually brings the model back.+ // The value of a loop is the re-check: a model that declares victory early+ // gets asked to prove it, with its own work in front of it.+ const loopState = opts?.loop ??+ (slash?.command.name === 'loop'+ ? (() => {+ const { intervalMs, rest } = parseLoopSpec(slash.args)+ return { pass: 1, intervalMs, task: rest || rawInstruction, startedAt: Date.now() }+ })()+ : null)const store = useChatStore.getState()const codexStore = useCodexStore.getState()@@ -670,17 +693,16 @@ export function useCodex() {// backstop. Floor of 1 so a stray 0 setting can't zero the loop.const MAX_CODEX_ITERATIONS = Math.max(settings.agentMaxIterations ?? 200, 1)for (let i = 0; i < MAX_CODEX_ITERATIONS && runningRef.current && !abort.signal.aborted; i++) {- // `/loop 20m …` — a real wall-clock deadline, checked between- // iterations. Never mid-tool: a run cut off inside file_edit or a shell- // command would leave the workspace in a state nobody asked for. So the- // budget is "no NEW step after this point", not a hard kill.- if (loopDeadline && Date.now() > loopDeadline && i > 0) {+ // A loop's TOTAL runtime ceiling, checked between iterations so a run is+ // never cut off inside a file_edit or a shell command. This is the+ // runaway guard across all passes, not a deadline for the work.+ if (loopState && Date.now() - loopState.startedAt > MAX_LOOP_TOTAL_MS && i > 0) {const done = fullContent.trim()useChatStore.getState().updateMessageContent(convId!,assistantMsg.id,(done ? done + '\n\n' : '') +- `_(time is up: the ${formatDuration(loopBudgetMs!)} budget for this loop ran out after ${i} step${i === 1 ? '' : 's'}. Nothing was cut off mid-step. Send /loop again with a longer budget to carry on.)_`,+ `_(this loop has been running for ${formatDuration(MAX_LOOP_TOTAL_MS)} and stopped there. Nothing was cut off mid-step.)_`,)break}@@ -1714,10 +1736,64 @@ export function useCodex() {abortRef.current = nullclearActiveChatId()codexStore.setThreadStatus(convId, 'idle')++ // ── /loop driver ───────────────────────────────────────────────────+ // The pass is over. A loop is not "one long turn": it is the model being+ // brought BACK with its own work in front of it and asked to prove the+ // claim. That is the whole value, and it is why the interval is a pause+ // between passes rather than a deadline for the task.+ //+ // We stop on LOOP_DONE, on the pass cap, on the total-time ceiling, or+ // when the user hits stop (loopTimerRef is cleared there).+ if (loopState && convId && !userStoppedRef.current) {+ const answer = fullContent.trim()+ const saidDone = new RegExp(`(^|\\s)${LOOP_DONE_MARKER}\\s*$`).test(answer)+ const elapsed = Date.now() - loopState.startedAt+ const nextPass = loopState.pass + 1++ if (saidDone) {+ // Nothing to do — the marker is stripped from the display by+ // cleanCodexText, so the user just sees the answer.+ } else if (nextPass > MAX_LOOP_PASSES) {+ useChatStore.getState().addMessage(convId, {+ id: uuid(), role: 'assistant', timestamp: Date.now(),+ content: `Stopped after ${MAX_LOOP_PASSES} passes without a clean finish. What is above is where it got to. Send /loop again to keep going, or take it from here yourself.`,+ })+ } else if (elapsed > MAX_LOOP_TOTAL_MS) {+ useChatStore.getState().addMessage(convId, {+ id: uuid(), role: 'assistant', timestamp: Date.now(),+ content: `Stopped after ${formatDuration(elapsed)} of looping. What is above is where it got to.`,+ })+ } else {+ const convForLoop = convId+ loopTimerRef.current = setTimeout(() => {+ loopTimerRef.current = null+ // Bail if the user moved on or started something else meanwhile.+ if (runningRef.current) return+ if (useChatStore.getState().activeConversationId !== convForLoop) return+ void sendRef.current?.(buildLoopRecheck(loopState.task, nextPass), {+ displayContent: `pass ${nextPass} of ${MAX_LOOP_PASSES}`,+ loop: { ...loopState, pass: nextPass },+ })+ }, loopState.intervalMs)+ }+ }}}, [])+ // Self-reference so the /loop driver can start the next pass. A plain+ // recursive call is not possible inside the useCallback that defines it.+ const sendRef = useRef<typeof sendInstruction | null>(null)+ sendRef.current = sendInstruction+const stopCodex = useCallback(() => {+ // Stop means stop: also cancel a /loop pass that is waiting out its+ // interval, otherwise the run the user just killed comes back by itself.+ userStoppedRef.current = true+ if (loopTimerRef.current) {+ clearTimeout(loopTimerRef.current)+ loopTimerRef.current = null+ }runningRef.current = falseabortRef.current?.abort()abortRef.current = nulldiff --git a/src/lib/__tests__/agent-commands.test.ts b/src/lib/__tests__/agent-commands.test.tsindex 0738d27b..c73251a2 100644--- a/src/lib/__tests__/agent-commands.test.ts+++ b/src/lib/__tests__/agent-commands.test.ts@@ -4,10 +4,14 @@ import {getAgentCommand,parseAgentCommand,matchAgentCommands,- parseLoopBudget,+ parseLoopSpec,+ buildLoopRecheck,formatDuration,- DEFAULT_LOOP_BUDGET_MS,- MAX_LOOP_BUDGET_MS,+ DEFAULT_LOOP_INTERVAL_MS,+ MAX_LOOP_INTERVAL_MS,+ MAX_LOOP_PASSES,+ LOOP_DONE_MARKER,+ LOOP_CONTINUE_MARKER,} from '../agent-commands'import { MUTATING_TOOLS } from '../mutating-tools'@@ -61,15 +65,6 @@ describe('AGENT_COMMANDS registry', () => {expect(AGENT_COMMANDS.filter((c) => c.handledLocally).map((c) => c.name)).toEqual(['goal'])})- it('/loop refuses to fake a green result', () => {- const t = getAgentCommand('loop')!.build('make the tests pass')- expect(t).toContain('Never loosen the check to make it pass')- expect(t).toContain('never delete or skip a test to go green')- // And it has to stop rather than spin: a loop with no exit burns a cloud- // budget until the iteration cap saves it.- expect(t).toContain('Stop EARLY')- })-it('an argument the user typed always reaches the expansion', () => {// A template that silently drops its args looks like it worked and does the// wrong thing, which is worse than refusing.@@ -215,44 +210,75 @@ describe('matchAgentCommands (autocomplete)', () => {})})-describe('/loop time budget', () => {+describe('/loop interval', () => {+ // The interval is the PAUSE BETWEEN PASSES, not a deadline. An earlier build+ // treated it as a time limit and Qwen3-32B then tried to cram the whole task+ // into 30 seconds (David, 2026-07-25).it('reads the compact forms', () => {- expect(parseLoopBudget('20m fix the tests').budgetMs).toBe(20 * 60_000)- expect(parseLoopBudget('2h refactor').budgetMs).toBe(2 * 3_600_000)- expect(parseLoopBudget('90s smoke').budgetMs).toBe(90_000)- expect(parseLoopBudget('1h30m big job').budgetMs).toBe(90 * 60_000)- expect(parseLoopBudget('45 something').budgetMs).toBe(45 * 60_000) // bare = minutes+ expect(parseLoopSpec('30s fix the tests').intervalMs).toBe(30_000)+ expect(parseLoopSpec('20m fix the tests').intervalMs).toBe(20 * 60_000)+ // Capped: an interval longer than half an hour is not a loop cadence.+ expect(parseLoopSpec('1h30m big job').intervalMs).toBe(MAX_LOOP_INTERVAL_MS)+ // Bare number = minutes, also subject to the cap.+ expect(parseLoopSpec('10 something').intervalMs).toBe(10 * 60_000)})- it('strips the duration out of the task text', () => {- expect(parseLoopBudget('20m fix the tests').rest).toBe('fix the tests')- expect(parseLoopBudget('2h: refactor the parser').rest).toBe('refactor the parser')+ it('strips the interval out of the task text', () => {+ expect(parseLoopSpec('30s fix the tests').rest).toBe('fix the tests')+ expect(parseLoopSpec('2h: refactor the parser').rest).toBe('refactor the parser')})- it('falls back to a default when no duration is given', () => {- const r = parseLoopBudget('make the build green')- expect(r.budgetMs).toBe(DEFAULT_LOOP_BUDGET_MS)+ it('falls back to a short default when none is given', () => {+ const r = parseLoopSpec('make the build green')+ expect(r.intervalMs).toBe(DEFAULT_LOOP_INTERVAL_MS)expect(r.rest).toBe('make the build green')})- it('caps a runaway budget', () => {- // A forgotten loop must not be able to bill a whole day of cloud.- expect(parseLoopBudget('99h forever').budgetMs).toBe(MAX_LOOP_BUDGET_MS)+ it('caps a silly interval', () => {+ expect(parseLoopSpec('99h forever').intervalMs).toBe(MAX_LOOP_INTERVAL_MS)+ })++ it('does not mistake a task that mentions a duration for an interval', () => {+ expect(parseLoopSpec('fix 20m of flakiness').intervalMs).toBe(DEFAULT_LOOP_INTERVAL_MS)+ expect(parseLoopSpec('fix 20m of flakiness').rest).toBe('fix 20m of flakiness')+ })++ it('tells the model it will be brought BACK, not that it has a deadline', () => {+ const t = getAgentCommand('loop')!.build('30s make the tests pass')+ expect(t).toContain('pass 1 of a LOOP')+ expect(t).toContain('bring you back roughly every 30s')+ expect(t).toContain(`up to ${MAX_LOOP_PASSES} passes`)+ // The exact wording that caused the misread must not come back.+ expect(t).not.toContain('You have 30s')+ expect(t).not.toMatch(/time is up|budget/i)})- it('does not mistake a task that starts with a number for a budget', () => {- // "3 failing tests" is the job, not the clock. Only a compact duration- // token counts, and a bare number is read as minutes by design, so this- // pins the shapes that must NOT be swallowed silently.- expect(parseLoopBudget('fix 20m of flakiness').budgetMs).toBe(DEFAULT_LOOP_BUDGET_MS)- expect(parseLoopBudget('fix 20m of flakiness').rest).toBe('fix 20m of flakiness')+ it('makes the model declare done or continue explicitly', () => {+ const t = getAgentCommand('loop')!.build('make the tests pass')+ expect(t).toContain(LOOP_CONTINUE_MARKER)+ expect(t).toContain(LOOP_DONE_MARKER)+ })++ it('still refuses to fake a green result', () => {+ const t = getAgentCommand('loop')!.build('make the tests pass')+ expect(t).toContain('Never loosen a check to make it pass')+ expect(t).toContain('never delete or skip a test to go green')+ })+})++describe('buildLoopRecheck — the actual point of a loop', () => {+ it('makes the model audit its own last pass instead of trusting it', () => {+ const t = buildLoopRecheck('make the tests pass', 3)+ expect(t).toContain('pass 3')+ expect(t).toContain('make the tests pass')+ expect(t).toContain('Do not assume the previous pass was right')+ expect(t).toContain('claimed as done that you have not PROVEN')})- it('states the budget in the prompt it sends', () => {- const t = getAgentCommand('loop')!.build('20m make the tests pass')- expect(t).toContain('You have 20m')- expect(t).toContain('The app enforces it')- expect(t).not.toContain('20m make the tests pass') // duration is consumed+ it('prices the two markers honestly, so DONE is not the cheap option', () => {+ const t = buildLoopRecheck('x', 2)+ expect(t).toContain(`an honest ${LOOP_CONTINUE_MARKER} costs one more pass`)+ expect(t).toContain(`a wrong ${LOOP_DONE_MARKER} ships a broken result`)})})diff --git a/src/lib/__tests__/readonly-enforcement.test.ts b/src/lib/__tests__/readonly-enforcement.test.tsindex ba7b8813..c8c1bdac 100644--- a/src/lib/__tests__/readonly-enforcement.test.ts+++ b/src/lib/__tests__/readonly-enforcement.test.ts@@ -85,25 +85,49 @@ describe('both hooks still carry the guard', () => {})})-describe('/loop budget is enforced in the run, not just stated', () => {- it('useCodex checks the wall clock between iterations', () => {+describe('/loop actually loops', () => {+ // David, 2026-07-25: a loop is not a deadline. `/loop 30s <task>` means come+ // back every 30 seconds and check again, so the agent cannot forget a piece+ // and cannot get away with an early "done". An earlier build read the number+ // as a time limit and Qwen3-32B tried to cram the whole task into 30 seconds.+ it('derives the interval from the command, not from a setting', () => {const src = read('../../hooks/useCodex.ts')- // The deadline has to be derived from the command, not from a setting.- expect(src).toContain("slash?.command.name === 'loop' ? parseLoopBudget(slash.args).budgetMs : null")- expect(src).toContain('if (loopDeadline && Date.now() > loopDeadline && i > 0)')- // And it must report the stop rather than going quiet.- expect(src).toContain('time is up')+ expect(src).toContain("slash?.command.name === 'loop'")+ expect(src).toContain('parseLoopSpec(slash.args)')})- it('the check sits at the TOP of the iteration, never mid-tool', () => {+ it('starts the NEXT pass after the interval instead of killing the run', () => {+ const src = read('../../hooks/useCodex.ts')+ expect(src).toContain('loopTimerRef.current = setTimeout(')+ expect(src).toContain('buildLoopRecheck(loopState.task, nextPass)')+ expect(src).toContain('}, loopState.intervalMs)')+ })++ it('stops on the done marker, the pass cap and the total ceiling', () => {+ const src = read('../../hooks/useCodex.ts')+ expect(src).toContain('LOOP_DONE_MARKER')+ expect(src).toContain('nextPass > MAX_LOOP_PASSES')+ expect(src).toContain('elapsed > MAX_LOOP_TOTAL_MS')+ })++ it('stop cancels a pass that is waiting out its interval', () => {+ // Otherwise the run the user just killed comes back by itself.+ const src = read('../../hooks/useCodex.ts')+ const stopIdx = src.indexOf('const stopCodex = useCallback(')+ expect(stopIdx).toBeGreaterThan(0)+ const stopBody = src.slice(stopIdx, stopIdx + 600)+ expect(stopBody).toContain('clearTimeout(loopTimerRef.current)')+ expect(stopBody).toContain('userStoppedRef.current = true')+ })++ it('the total ceiling is checked between iterations, never mid-tool', () => {const src = read('../../hooks/useCodex.ts')const loopHead = src.indexOf('for (let i = 0; i < MAX_CODEX_ITERATIONS')- const deadline = src.indexOf('if (loopDeadline && Date.now() > loopDeadline')+ const ceiling = src.indexOf('MAX_LOOP_TOTAL_MS && i > 0')const firstExec = src.indexOf('budget.addToolCalls(')- expect(loopHead).toBeGreaterThan(0)- expect(deadline).toBeGreaterThan(loopHead)+ expect(ceiling).toBeGreaterThan(loopHead)// Cutting a run off inside file_edit or a shell command would leave the// workspace in a state nobody asked for.- expect(deadline).toBeLessThan(firstExec)+ expect(ceiling).toBeLessThan(firstExec)})})diff --git a/src/lib/agent-commands.ts b/src/lib/agent-commands.tsindex 73b8a736..5bf2db8c 100644--- a/src/lib/agent-commands.ts+++ b/src/lib/agent-commands.ts@@ -50,26 +50,40 @@ export interface AgentCommand {/** Shared closing line so every command nudges the agent to act, not narrate. */const ACT = 'Use your tools to do this for real — do not just describe the steps. Be concise in text; the work happens in tool calls. Reply in the user\'s language.'-/** Longest budget /loop will accept. Beyond this it is not a loop, it is a job. */-export const MAX_LOOP_BUDGET_MS = 4 * 60 * 60 * 1000-/** Used when the user gives no duration — long enough to be useful, short- * enough that a forgotten loop cannot quietly bill an afternoon of cloud. */-export const DEFAULT_LOOP_BUDGET_MS = 15 * 60 * 1000+/** How long the whole loop may run across all passes. A ceiling, not a deadline+ * for the work: a forgotten loop must not bill an afternoon of cloud. */+export const MAX_LOOP_TOTAL_MS = 4 * 60 * 60 * 1000+/** How many passes before we stop and hand back. */+export const MAX_LOOP_PASSES = 10+/** Pause between passes when the user names none. Short, because the value of a+ * loop is the re-check, not the waiting. */+export const DEFAULT_LOOP_INTERVAL_MS = 5 * 1000+/** Longest pause we will sit idle between passes. */+export const MAX_LOOP_INTERVAL_MS = 30 * 60 * 1000++/** The model ends a pass with one of these so the driver knows what to do. */+export const LOOP_DONE_MARKER = 'LOOP_DONE'+export const LOOP_CONTINUE_MARKER = 'LOOP_CONTINUE'/**- * Pull a leading duration off `/loop`'s arguments: `20m`, `2h`, `90s`,- * `1h30m`, or a bare number read as minutes. Returns the budget in ms plus+ * Pull a leading interval off `/loop`'s arguments: `30s`, `20m`, `2h`,+ * `1h30m`, or a bare number read as minutes. Returns the interval in ms plus* the remaining task text.*- * The budget is REAL — useCodex stops the run when the clock runs out — so- * parsing has to be strict about what counts as a duration. "5 minutes to- * midnight" is a task, not a budget, which is why only a compact token at the- * very start is accepted.+ * This is the PAUSE BETWEEN PASSES, not a deadline. `/loop 30s <task>` means+ * "work on it, then every 30 seconds look again and keep going until it is+ * genuinely done" — the point is the repeated re-examination, so a model that+ * declares victory early gets caught. An earlier version read it as a time+ * limit, and Qwen3-32B then tried to cram the whole task into 30 seconds+ * (David, 2026-07-25).+ *+ * Only a compact token at the very start counts, so "fix 20m of flakiness"+ * stays a task.*/-export function parseLoopBudget(args: string): { budgetMs: number; rest: string } {+export function parseLoopSpec(args: string): { intervalMs: number; rest: string } {const text = args.trim()const m = /^(\d+\s*h(?:\s*\d+\s*m)?|\d+\s*m(?:in)?|\d+\s*s(?:ec)?|\d+)\b[\s,:-]*/i.exec(text)- if (!m) return { budgetMs: DEFAULT_LOOP_BUDGET_MS, rest: text }+ if (!m) return { intervalMs: DEFAULT_LOOP_INTERVAL_MS, rest: text }const token = m[1].replace(/\s+/g, '').toLowerCase()let ms = 0@@ -79,8 +93,27 @@ export function parseLoopBudget(args: string): { budgetMs: number; rest: stringelse if (/^\d+s(ec)?$/.test(token)) ms = parseInt(token, 10) * 1000else ms = parseInt(token, 10) * 60_000 // bare number = minutes- if (!ms) return { budgetMs: DEFAULT_LOOP_BUDGET_MS, rest: text }- return { budgetMs: Math.min(ms, MAX_LOOP_BUDGET_MS), rest: text.slice(m[0].length).trim() }+ if (!ms) return { intervalMs: DEFAULT_LOOP_INTERVAL_MS, rest: text }+ return { intervalMs: Math.min(ms, MAX_LOOP_INTERVAL_MS), rest: text.slice(m[0].length).trim() }+}++/**+ * The instruction for pass 2 and beyond. The whole point of the loop: make the+ * model re-read the ORIGINAL task and audit its own last pass, because "done"+ * from a model that just did work is the least reliable claim it makes.+ */+export function buildLoopRecheck(task: string, pass: number): string {+ return `This is pass ${pass} of a loop on this task:++${task}++Do not assume the previous pass was right. Re-read the task, then check the actual current state with your tools — the files, the test run, the build. Specifically:+- Anything claimed as done that you have not PROVEN is still open. Prove it or fix it.+- Anything the task asks for that has not been touched at all.+- Anything the last pass broke on the way.++If work remains, do it now and end your reply with ${LOOP_CONTINUE_MARKER} on its own line.+If everything the task asks for is done AND verified, end your reply with ${LOOP_DONE_MARKER} on its own line, and name the check that proved it. Do not write ${LOOP_DONE_MARKER} on a hunch — an honest ${LOOP_CONTINUE_MARKER} costs one more pass, a wrong ${LOOP_DONE_MARKER} ships a broken result. ${ACT}`}/** "20m" / "1h 30m" / "45s" for the prompt and the UI. */@@ -116,24 +149,23 @@ export const AGENT_COMMANDS: AgentCommand[] = [},{name: 'loop',- summary: 'Keep working until it is done, within a time budget',- argHint: '[20m] <task, and how you will know it is done>',+ summary: 'Work, then re-check again and again until it is really done',+ argHint: '[30s] <task, and how you will know it is done>',build: (a) => {- const { budgetMs, rest } = parseLoopBudget(a)+ const { intervalMs, rest } = parseLoopSpec(a)const task = rest || 'the task the user just described'- const budgetLine = budgetMs- ? `\n\nYou have ${formatDuration(budgetMs)}. The app enforces it: when the time is up the run stops wherever it is, so spend it on the work and not on narration. If you can see you will not finish in time, say what you would do next and stop early rather than being cut off mid-edit.`- : ''- return `Work on this until it is genuinely finished: ${task}${budgetLine}+ return `Work on this: ${task}++This is pass 1 of a LOOP. The app will bring you back roughly every ${formatDuration(intervalMs)} to look at it again, up to ${MAX_LOOP_PASSES} passes, and each time you will be asked to prove what you claimed. So do not rush to a finish and do not pad the answer.-Run it as a loop, not a single pass:+Each pass:1) Do the next concrete step.2) VERIFY it — run the tests, the build, the command, whatever actually proves it. Reading your own change back is not verification.-3) If the check fails, fix the cause and go back to step 2.+3) If the check fails, fix the cause and check again.-Stop when the finish condition is met, and say which check proved it.+End this reply with ${LOOP_CONTINUE_MARKER} on its own line if anything is left, or ${LOOP_DONE_MARKER} on its own line if everything the task asks for is done AND verified, naming the check that proved it. A wrong ${LOOP_DONE_MARKER} ships a broken result; an honest ${LOOP_CONTINUE_MARKER} costs one more pass.-Stop EARLY and say so plainly if: the same fix fails twice in a row, the next step needs a decision only the user can make, or you would have to guess at something you cannot look up. A loop that reports honest failure after three rounds is worth more than one that keeps going and reports success it did not earn. Never loosen the check to make it pass, and never delete or skip a test to go green. ${ACT}`+Say so plainly and end with ${LOOP_DONE_MARKER} if you are genuinely stuck: the same fix failing twice, a decision only the user can make, or something you would have to guess at. Never loosen a check to make it pass, and never delete or skip a test to go green. ${ACT}`},},