Skip to content

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 ​

ScenarioThe inline task doesReturns
Environment setupSeveral Bash calls: install dependencies, create config, start a service, check the portDone or failed, with the output of the failing step
Drive Playwright (MCP or CLI)Opens a page, clicks through steps, takes screenshotsPass or fail per step, screenshot paths
Log extractionGreps and reads large logs, correlates timestampsThe lines or values asked for
CI failure triageFetches a CI log (Jenkins, GitHub Actions), finds the first errorFailing test, error message, file:line
Test runRuns the test suite, parses the outputOnly the failures, with message
Pre-push scanReads git diff origin/<base>...HEAD, checks added lines for hostnames, names, tokens, home pathsFindings with file:line, or clean
Git choresRewrites commit times, cherry-picks, writes a commit message from the diffResult and new SHAs
Tracker fetchgh issue view with comments and linked PRsShort summary of the ticket state
Docs lookupContext7 or web docs queryThe exact API signature or config snippet
Code locationGrep and Glob over the repo for call sites of a symbolList of file:line
Mechanical editRenames in a few files, updates imports, applies lint autofix, updates snapshotsFiles changed and check result
License checkReads a dependency's package metadata and LICENSELicense and compliance note
Data conversionParses JSON, YAML or CSV output into the shape the caller needsConverted data
Worker statusReads an orchestration worker transcriptStatus 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, /clear and 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, Grep and Glob by default. Bash, Write, Edit and 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 ​

LimitValue
TurnsNo limit, unless the call sets maxTurns (at most 30)
Output tokens16,000
Time10 minutes, then it moves to the background (background: 30 minutes in all)
Running at once3 per session, background runs included
Prompt20,000 characters
Files given to the task20 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:

SettingDefaultMeaning
Let the agent run inline tasksOnOff: turns that start later have no inline_task tool
Claude modelhaikuModel for Claude Code sessions
OpenCode modelemptyprovider/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 Bash or edit step the agent granted, as the session itself would. The request shows in the session like any other.

MIT licensed. Unofficial; not affiliated with Anthropic.