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 errorsNormally 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 failedand the reason. - The agent is stuck. After three checks in a row with no progress, the goal waits for you (
waiting for youin 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
| Command | Effect |
|---|---|
| /goal <condition> | Set a goal and start working on it. Replaces any current goal. |
| /goal | Show the goal, its status, elapsed time, turns and tokens used. Same as /goal status. |
| /goal pause | Stop continuing automatically. The goal is kept. |
| /goal resume | Continue 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 clear | Remove 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:
| Setting | Default | Limit |
|---|---|---|
| goal.maxTurns | 75 | Turns. |
| goal.maxDurationMinutes | 45 | Minutes. Checked between turns, so a running step isn't cut off. |
| goal.maxTokens | 500000 | Growth of the conversation's context during the run. Compaction brings it back down. |
{ "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 cardSets 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.
Loops
/loop 10m check the CI status of this branch and fix anything that failed
/loop keep the dependency updates PR green
/loopA loop sends the same prompt to the session repeatedly. There are three kinds:
| You type | Kind | Runs |
|---|---|---|
| /loop 10m <prompt> | Fixed interval | Every 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-paced | Now, then after each run a model picks the next delay, between 1 and 60 minutes. |
| /loop | Maintenance | Now, 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
| Command | Effect |
|---|---|
| /loop status | Show the loop. A bare /loop does the same while one is running. |
| /loop pause | Stop running it. It's kept. |
| /loop resume | Start again. The next run is one interval away (5 minutes for self-paced loops). |
| /loop stop | Remove 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.
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".