Skip to content

[FEATURE]: subagent option to start the child as a fork of the parent conversation #58182

Open

Description

@iceteaSA

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Add an option to the subagent tool that starts the child as a fork of the parent conversation, not with fresh context.

Today the tool description says: "New child sessions start with fresh context, so include all relevant context and instructions when you don't pass a sessionID" (subagent.ts#L58). For a side task that must use what the parent knows, the model must copy that context into the prompt. This costs output tokens, can drop details, and sends a new prompt prefix that the provider cache does not hold.

Most of the parts exist:

  • Sessions already store a fork source and boundary (fork: { sessionID, boundary }), and /fork copies history up to a message.
  • SessionAffinity.get already gives a child the parent's cache routing key (session.parentID ?? session.fork?.sessionID ?? session.id, affinity.ts#L6-L8). A forked child can thus reuse the parent's cached prefix with the same model.

Request:

  1. A subagent input such as context: "fresh" | "fork" (default fresh). With fork, the child gets the parent's history up to the current tool call, plus the new prompt. The child keeps parentID, so status, notices, and interruption work as for other children.
  2. The same option for plugins that start child sessions, so that a plugin dispatcher can use it.
  3. A clear rule for the parts that change between parent and child (agent, model, tools, permissions). The cache benefit applies only when the model stays the same.

Related: #51383 asks for shared precached state across subagents. This request is narrower: one child that continues from the parent's conversation.

Claude Code has a similar function: "fork mode is on by default in interactive sessions, so Claude can delegate a side task to a subagent that inherits the full conversation".

Activity

  1. opencode-agent commented on Oct 22, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up, @iceteaSA! To restate the request: you'd like an option on the subagent tool (and on the API plugins use to start child sessions) that starts the child as a fork of the parent conversation instead of fresh context. The child keeps parentID, and when it uses the same model it reuses the parent's cached prefix.

    This is already being worked on:

    • feat(core): add experimental subagent context forking #47576: an open PR that adds an experimental fork parameter to subagent (behind experimental.subagent_fork). The child gets the parent's history up to the spawning message, keeps its parent ownership and can still have its agent and model set. Neither the PR nor this request settles what happens to tools and permissions when they differ from the parent's.

    Related issues:

    A plugin can't add this today, because the plugin API has no way to create a forked child session. Your point 2 would need an addition to that API. Maintainers will consider it together with the PR above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions