Inline tasks
An inline task is a mid-size job that Claude runs inside one tool call. A small model with a minimized context does the work with the tools it is granted and returns only the result. Your session's context grows by the result, not by every intermediate output.
An inline task is not a session: it has no entry in the session list and no transcript of its own. It appears as a card under the inline_task tool call.
When to use it
In a Claude Code session the tool is always loaded (OpenCode sessions do not do this): its description is in the first prompt of every turn, so the agent sees it without a tool search. The agent reads these rules (the same text is its guidance):
Prefer inline_task over Agent (haiku, Explore, general-purpose) when the task:
- is mechanical: search, read logs, run tests, extract, summarize, classify, format, small edit;
- needs no judgment or design, and no parent conversation context beyond what fits in prompt + files;
- needs only the result, not the raw output.
Use a subagent instead when the task needs judgment or design, long exploration, parallel runs, or parent context. Do it directly when 1-2 tool calls suffice, or when the next step needs the raw output.
Grant the least: tools default to Read, Grep, Glob; add Bash, Write, Edit or an MCP server only when needed.
Set run_in_background for runs of minutes (tests, build, e2e) when you have other work: the result arrives as a notice, do not poll. inline_task_output reads progress, inline_task_stop stops it.
Scenarios
| Scenario | The inline task does | Returns |
|---|---|---|
| Environment setup | Several Bash calls: install dependencies, create config, start a service, check the port | Done or failed, with the output of the failing step |
| Drive Playwright (MCP or CLI) | Opens a page, clicks through steps, takes screenshots | Pass or fail per step, screenshot paths |
| Log extraction | Greps and reads large logs, correlates timestamps | The lines or values asked for |
| CI failure triage | Fetches a CI log (Jenkins, GitHub Actions), finds the first error | Failing test, error message, file:line |
| Test run | Runs the test suite, parses the output | Only the failures, with message |
| Pre-push scan | Reads git diff origin/<base>...HEAD, checks added lines for hostnames, names, tokens, home paths | Findings with file:line, or clean |
| Git chores | Rewrites commit times, cherry-picks, writes a commit message from the diff | Result and new SHAs |
| Tracker fetch | gh issue view with comments and linked PRs | Short summary of the ticket state |
| Docs lookup | Context7 or web docs query | The exact API signature or config snippet |
| Code location | Grep and Glob over the repo for call sites of a symbol | List of file:line |
| Mechanical edit | Renames in a few files, updates imports, applies lint autofix, updates snapshots | Files changed and check result |
| License check | Reads a dependency's package metadata and LICENSE | License and compliance note |
| Data conversion | Parses JSON, YAML or CSV output into the shape the caller needs | Converted data |
| Worker status | Reads an orchestration worker transcript | Status and open question |
The card
The card sits under the tool call. It shows the status, the task, and model · turns · tokens. While it runs, Stop cancels the task; the result then comes back as stopped, with what was done so far.
- Steps (tools the task called) are collapsed. Open them to follow the work.
- The result is shown as text, with the list of changed files.
- A permission request of the task shows in the session like any other, and the card opens on it. See Permissions & modes.
Background runs
The agent can start an inline task in the background (run_in_background), for example a full test suite or a build. The call returns at once and the agent ends its turn or goes on with other work.
- The card shows Background and Running while the task runs. Its steps and permission requests show as for any inline task; a request while the session is idle sets the session to needs input.
- When the task ends, the card shows the result and the agent gets it as a notice, which starts a new turn.
- Stop on the card asks first. A stopped task starts no turn: the agent is told with your next message.
- Stopping the session's turn (Esc or Stop) does not stop a background task. Closing or deleting the session,
/clearand a daemon restart do. After a restart the card shows Stopped with the note "The daemon stopped while this ran." (after a close or/clear: "The session was closed while this ran." or "The conversation was cleared while this ran."), and the agent is told with your next message. - The agent can read a running task's progress (
inline_task_output) and stop it (inline_task_stop); it does not need to poll, the result arrives as a notice. - Rewinding the session is refused while a background task runs: stop the task first.
- In a Claude session, a running foreground task can be moved to the background: the Run in background button on its card, or Ctrl+Shift+B. The call returns at once and the task goes on as a background task. A foreground task that reaches 10 minutes moves the same way instead of stopping; its total limit is then 30 minutes.
- Time limit: 30 minutes. The session counts as working while the task runs, so it is not closed when idle and an update waits for it.
- OpenCode sessions (OpenCode 1 and 2) support background runs the same way. Differences: the result notice reaches the model as a hidden message; after a close or
/clear, a later restore says "The daemon stopped while this ran." instead of the cause.
What the task can use
- Tools:
Read,GrepandGlobby default.Bash,Write,Editand MCP servers of the session (for example Playwright) only when the agent grants them. - Permissions: the mode and rules of the session apply to every tool call. The task never gets more than the session has.
- No CLAUDE.md, no memory, no skills. The PreToolUse hooks of the session (for example a hook that denies Bash) also run inside an inline task; its other hooks and plugin hooks do not. The task never starts other agents, and never gets the claude-ui or orchestration tools.
- Account: the same as the session (subscription or API key). No separate key.
Limits
| Limit | Value |
|---|---|
| Turns | No limit, unless the call sets maxTurns (at most 30) |
| Output tokens | 16,000 |
| Time | 10 minutes, then it moves to the background (background: 30 minutes in all) |
| Running at once | 3 per session, background runs included |
| Prompt | 20,000 characters |
| Files given to the task | 20 files, about 250,000 bytes in total in the prompt |
A file that does not fit in the prompt is not rejected: the prompt names its path and size, and the task reads it with Read and Grep (both are added to its tools when the agent did not grant them). Files are added in the order given.
At a limit the task stops and returns the partial result with the reason (turns, tokens or time).
Settings
In Settings › Sessions › Features:
| Setting | Default | Meaning |
|---|---|---|
| Let the agent run inline tasks | On | Off: turns that start later have no inline_task tool |
| Claude model | haiku | Model for Claude Code sessions |
| OpenCode model | empty | provider/model for OpenCode sessions. Empty: OpenCode's small_model, else the session's model |
Good to know
- In a Claude Code session the steps are stored with the session, like the steps of a subagent run, so after a daemon restart or a reload the card still shows them. They do not appear in
claude --resume. A run from before this was stored, and a run in an OpenCode session, shows the result, model, turns, tokens and files with the note "The steps of this run were not kept." - Rewinding the code of a session does not undo files an inline task changed.
- The list of changed files comes from the Edit and Write steps and from
git status. A file that was already modified before the task and changed again only by a Bash command is not listed. Outside a git repository only Edit and Write steps count.
OpenCode sessions
Inline tasks work in OpenCode sessions with these gaps:
- OpenCode keeps its base prompt and
AGENTS.md, so the context is smaller by tools and history only, not by instructions. - The turn limit is enforced after the turn by stopping the task, not by the model.
- If the call cannot be matched to the running call, the task still runs and returns its result, but the card has no steps.
- In Ask before edits, an inline task of an OpenCode 1 session asks before a
Bashor edit step the agent granted, as the session itself would. The request shows in the session like any other.