ML.ai

Hand off a job and keep your main session free

Background runs let you delegate a task to a separate session. The run persists even if you close, hide, or reload the panel. When it finishes, the output appears as a draft in your composer.

ML.ai
New sessionAutomationsReview

Sessions

Explain how auth refresh worksnowAdd input validation to the signup formFind and fix the failing test40sRotate refresh tokens on use1hUpgrade to React 192d
acme/storefrontmain

Explain how auth refresh works

refresh() in src/auth/session.ts rotates the token pair 60 seconds before expiry.

session.tslines 41-42

41if (expiresAt - now() < 60_000)42  return rotate(tokens)

Find and fix the failing test

Background tasks

Running

Add input validation to the signup formgeneral · write allowed

Read SignupForm.tsx, validate.ts

Ask ML.ai...↑

Who background runs are for

Developers juggling multiple tasks who want to delegate work without blocking their main conversation.

  • Developers with long jobs

    Test writing, refactors and migrations run in their own session while you keep chatting.

  • Anyone switching between tasks

    Ask a quick question or start something new while a run keeps working.

  • Reviewers who want a draft first

    Results land as a draft in your composer, so you edit before anything is sent.

How it works

Start a run from the composer, let it work in its own session, and pick up the result as a draft whenever you come back to the panel.

Delegate a job without blocking your conversation

Send the task to a background run and it opens its own session with its own context. Your main conversation stays open for questions, reviews or a second task.

Runs keep going when you close or reload the panel

The run lives in its own session, so closing, hiding or reloading the panel leaves it running. Open the panel again and you can see where it got to.

Fixes come back as one reviewable diff

The general subagent writes the change and runs the tests inside the background session. What reaches you is a single diff you can read before anything merges.

Pick up the result as a draft in your composer

When the run finishes, its output arrives as a draft in your composer. Read it, edit it or send it on, in your own time.

Running a job inline versus in the background

Run it inline

A long job holds up the conversation. You wait for it to finish before asking anything else, and a panel reload can cost you the context you built up.

In the background

The job gets its own session and you keep talking in the main one. Close or reload the panel and the run carries on, and the result shows up as a draft when it is done.

How a background run goes from start to draft

A background run moves through four stages, and you can step away at any of them without losing the work.

1Start the run from the composerWrite the task, choose a subagent with @, and send it to the background. A new session opens for that job alone.
2Keep working in your main sessionAsk questions, review code or start a second task while the run reads, writes and tests on its own.
3Close or reload the panel freelyThe run is tied to its own session instead of the panel, so hiding or reloading the panel leaves the job running.
4Review the draft it leaves youThe output appears as a draft in your composer. Read it, edit it and send it when you are ready.

Problems background runs solve

What to know before you hand a job to a background run.

Reloads that throw away the work

When a run is tied to the panel, a reload or a closed window ends it, and whatever progress it made goes with it.

How ML.ai handles it

The job runs in its own session, so the panel can close, hide or reload and the run keeps going until it finishes.

Long jobs that block the conversation

A big test-writing job running inline means you sit and wait, with no way to ask a quick question or start something else.

How ML.ai handles it

The background run takes the job off the main session, so the conversation in front of you stays free for anything else.

Results you cannot adjust first

Output posted straight into the chat is hard to trim or correct before it goes further, for example into a PR description.

How ML.ai handles it

Output arrives as a draft in your composer, so you decide what to keep, change or send.

ML.ai Settings
GeneralModelsAgentsSkillsMCP serversPermissionsUsage

Auto routing

Each step goes to the model that fits it

Agents

Pick a subagent and it stays selected until you swap it. Only general carries out changes end to end.

@explore · Where is the refresh token rotated?

› Searched refreshToken · 14 matches

› Read src/auth/session.ts, src/auth/rotate.ts

› Answered · 0 files changed

@exploreAsk ML.ai... @ to delegate

AutoBuild

Agents

How to hand work to subagents and pick the right one for each job.

ML.ai

Explorer

app/auth/login.tssession.tsMrotate.tsapi/me.tsmiddleware.tstests/session.test.tspackage.json

Found the refresh path. Updating the session helper now.

GreprefreshToken · 6 matches in app/auth

Fs.readapp/auth/session.ts

Fs.writeapp/auth/session.tspending

app/auth/session.ts2 lines changedlines 42-50

42export async function refresh(token) {

43 if (!token) return null;

44 if (!token?.exp) throw new Error('expired');

45 return await rotate(token);

46}

47

48async function rotate(token) {

49 const next = await issue(token.sub);

50 return next;

Permission requiredFs.write app/auth/session.ts

Permission prompts

How Allow, Always and Deny work for every edit and command, including the ones a background run makes.

FAQs

Can a background run write to the file system?

Yes. Edits from a background run go through the same Allow, Always or Deny prompt as your main session, with the real diff shown first, so nothing lands on disk without your say.

Which subagent should run a background job?

You pick the delegate when you start the run, and each option states up front whether it can write, so you choose the blast radius before committing. Only general carries out changes end to end; explore and architect read and plan without editing anything.

Where does the result of a background run go?

It drops into your composer as a draft. Nothing is sent on your behalf: you still review it and send it yourself, or dismiss it.

Hand off your next long job and keep coding

Start a background run from the composer, keep working in your main session, and pick up the result as a draft.