LatentCodeUsing LatentCode

Goals and loops

Let the agent keep working without you: a goal runs turn after turn until a condition is true; a loop runs a prompt again and again on a schedule.

Goals

/goal all tests in packages/api pass and npm run lint reports no errors

Normally the agent stops when it thinks it's done. With a goal, each time it stops, a separate model checks the recent conversation against your condition. If the condition isn't met, the agent is told what's missing and carries on. This repeats until:

  • The condition is met. The conversation shows ✓ Goal achieved.
  • It can't be met. If the checker decides the goal is impossible, the goal is cleared with ✗ Goal failed and the reason.
  • The agent is stuck. After three checks in a row with no progress, the goal waits for you (waiting for you in the sidebar). Send a message to help, or /goal resume.
  • A limit is reached (below). The agent is asked to wrap up, then the goal pauses.

While a goal is active, a GOAL chip appears under the prompt and the sidebar shows the condition and the turn count. Write conditions you could check yourself: name the command that must pass, the file that must exist, or the behavior that must be fixed.

Manage a goal

CommandEffect
/goal <condition>Set a goal and start working on it. Replaces any current goal.
/goalShow the goal, its status, elapsed time, turns and tokens used. Same as /goal status.
/goal pauseStop continuing automatically. The goal is kept.
/goal resumeContinue with fresh limits.
/goal edit <condition>Replace the condition without starting a run.
/goal append <text>Add to the condition and pass it to the agent straight away. /goal +<text> does the same.
/goal clearRemove the goal. stop, off and cancel work too.

Pressing esc twice interrupts the current turn; the goal then waits for you. The goal is stored with the session, so it survives quitting, resuming and compaction, and a forked session copies it.

Limits

Each run toward a goal stops at whichever limit comes first:

SettingDefaultLimit
goal.maxTurns75Turns.
goal.maxDurationMinutes45Minutes. Checked between turns, so a running step isn't cut off.
goal.maxTokens500000Growth of the conversation's context during the run. Compaction brings it back down.
latentcode.json
{ "goal": { "maxTurns": 120, "maxDurationMinutes": 90 } }

The counts start again each time you send a message or run /goal resume. Changes to the settings apply from the next /goal or /goal resume. The agent is warned as it gets close to a limit.

/bug-fix

/bug-fix checkout returns 500 when the cart contains a gift card

Sets a goal with a ready-made condition: find the root cause, make the smallest fix, add a regression test, and run the tests to prove it. Manage it with the /goal commands.

Which model checks the goal
Goal checks use a model your organization assigns for background work, or the session's model if none is assigned. Each check costs a small request.

Loops

/loop 10m check the CI status of this branch and fix anything that failed
/loop keep the dependency updates PR green
/loop

A loop sends the same prompt to the session repeatedly. There are three kinds:

You typeKindRuns
/loop 10m <prompt>Fixed intervalEvery 10 minutes, starting 10 minutes from now. Use s, m or h. You can also write the interval in the prompt: /loop check the deploy every 5 minutes.
/loop <prompt>Self-pacedNow, then after each run a model picks the next delay, between 1 and 60 minutes.
/loopMaintenanceNow, using the instructions in the nearest loop.md in your project, or built-in maintenance instructions if there isn't one.

Before each run the conversation shows ⟳ Loop fired · iteration N. A loop never interrupts a turn that's in progress; it waits for it to finish. The sidebar shows the prompt, the iteration and when the next run is due.

Manage a loop

CommandEffect
/loop statusShow the loop. A bare /loop does the same while one is running.
/loop pauseStop running it. It's kept.
/loop resumeStart again. The next run is one interval away (5 minutes for self-paced loops).
/loop stopRemove the loop. off, cancel and clear work too. esc also stops it while it's waiting for the next run.

Loops have no run limit and never expire; stop them when you're done. They're saved with the session and start again when you reopen LatentCode. A run that came due while LatentCode was closed runs once when you reopen it; missed runs don't pile up.

Loops cost money
Every run is a full agent turn on your usage. Pick an interval that matches how often things actually change.

FAQ

Can I use a goal with latentcode run?

Yes: latentcode run --command goal "all tests pass". Remember that run rejects anything that needs approval, so allow what the goal needs in your permissions.

The goal says it was achieved, but it isn't.

The checker only sees the recent conversation. Make the condition verifiable there: ask for a command whose output proves it, for example "npm test exits with 0 and prints the summary".