forking

forking is an agent for Claude Code from cubeplexai/cubepi. It costs 31 tokens per session (2,395 once invoked), scanned A, original, MIT.

A conversation-branching feature for CubePi agents, allowing a completed conversation run to be copied into a separate thread or tested temporarily.

In plain words
What is it for?
Use it to create persistent conversation branches or run one-off experiments from a specific completed response.
Why use it?
It lets developers explore an alternative answer without changing the original conversation.

Agent for Claude Code

Written for Claude Code: a Claude Code subagent (agents/*.md).

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/cubeplexai/cubepi/forking
Clone the repo
git clone --depth 1 https://github.com/cubeplexai/cubepi

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for forking

README.md
[![agentmods](https://agentmods.dev/badge/agents/cubeplexai/cubepi/forking.svg)](https://agentmods.dev/agents/cubeplexai/cubepi/forking)
Your own site
<a href="https://agentmods.dev/agents/cubeplexai/cubepi/forking"><img src="https://agentmods.dev/badge/agents/cubeplexai/cubepi/forking.svg" alt="Measured on agentmods" height="20"></a>
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,395 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00031 $0.02395
Opus 5 $0.00015 $0.01197
Sonnet 5 $0.00006 $0.00479
Haiku 4.5 $0.00003 $0.00239

Measured 6d ago against content hash e7f152ca69ed, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

forking scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

website/docs/guides/agents/forking.md · 251 lines

How it starts

The opening of the file, as written. The whole thing — 251 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Conversation Forking

A fork branches a conversation at a completed-run boundary. CubePi gives you two variants:

  • Agent.fork(...) — a persistent fork. Copies messages from the source thread up to and including a chosen run_id into a brand-new thread you can continue to converse with.
  • Agent.fork_once(...) — an ephemeral one-shot probe. Loads a snapshot in memory, runs one prompt, and returns the result without writing anything back to the source thread.

Both APIs key off run_id — a stable identifier for one prompt() → final assistant message cycle. Every message produced during a prompt carries the same run_id, so "the boundary after run R" is an unambiguous, reproducible cut.

The cubebox copy-button UX

The driving use case is the cubebox "branch this reply" button: under every assistant message in the UI there is a small affordance that forks the conversation into a fresh thread starting from the message above it. Users use it to explore "what if the assistant had answered this differently?" without polluting the original thread.

In that flow:

  • the host generates the new thread's id (cubebox uses uuid7),
  • calls Agent.fork(src, new, after_run_id=...) to materialise the branch, and
  • opens a fresh agent against the new thread.

The features below — explicit run_id, active_run_id, fork APIs, and the HITL binding rules — are exactly what that UX needs.

Agent.prompt(run_id=...) — accept-or-generate

Agent.prompt() now returns the run_id it used for the call:

run_id = await agent.prompt("hello")
print(run_id)  # → "8c0b…" — server-generated

Hosts that want to control the id (cubebox, multi-machine relays, anything that needs the id before the call completes) can supply it:

import uuid_extensions   # or whatever uuid7 source you prefer

my_run_id = uuid_extensions.uuid7str()
run_id = await agent.prompt("hello", run_id=my_run_id)
assert run_id == my_run_id

While the run is in flight, the id is available on Agent.state.active_run_id:

Read the full file on GitHub · 251 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 251 lines · 31 tokens per session scan A e7f152ca69ed

Subscribe to this mod's changes

forking is an agent published in the GitHub repository cubeplexai/cubepi (46 stars, last pushed 4d ago), licensed MIT. It adds 31 tokens to every session and 2,395 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.