Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
docs(agent): document session fork CLI
cyh2a09b33bf758
diff --git a/core/system_prompt_injection.py b/core/system_prompt_injection.pyindex 50b4ecb3c..4a1bf37e8 100644--- a/core/system_prompt_injection.py+++ b/core/system_prompt_injection.py@@ -170,6 +170,7 @@ Useful Harness queries include schema discovery, current session lookup, existin| External signal trigger | `vibe watch add` || Independent Agent delegation | `vibe agent run --create-session` || Same-session follow-up | `vibe agent run --session-id ...` |+| Branch from existing Session context | `vibe agent run --fork-session ...` || State/history inspection | `vibe data query`, `vibe runs list`, `vibe runs show` || Recurring specialist workflow | `vibe agent create/update` plus tasks, watches, or runs |@@ -179,6 +180,8 @@ Useful Harness queries include schema discovery, current session lookup, existinUse `vibe agent run --async --callback-session-id {default_session_id}` when one Agent delegates work to another Session and the final result text should return to this caller Session as a follow-up Agent message.+Use `vibe agent run --fork-session <source-session-id> --message ...` when work should branch from an existing Session's native backend context without mutating that source Session. Forks keep the source Session backend; `--agent`, `--model`, and `--reasoning-effort` may override the forked Session only when the backend stays the same. Do not combine `--fork-session` with `--session-id`, `--create-session`, `--deliver-key`, or `--post-to`.+`--post-to` changes the delivery target, not the session scope. Use `--post-to channel` when the session should stay thread-scoped but the follow-up message should be posted to the parent channel. For tasks, use `--message "..."` or `--message-file <path>` as the stored message. For watches, use `--prefix "..."` for the follow-up instruction prepended before waiter stdout.Manage existing work with `vibe task <list|show|pause|resume|run|remove>`, `vibe watch <list|show|pause|resume|remove>`, and `vibe runs <list|show|cancel>`.@@ -193,8 +196,10 @@ The table below is generated from currently enabled Agents at prompt-injection tRules:- All Agents listed in the generated table are enabled. Use the `Agent Name` value exactly as listed in shell commands such as `vibe agent show <agent-name>` and `vibe agent run --agent <agent-name> ...`.- `--session-id <id>` resumes that exact Agent Session and its transcript, backend identity, Show Page, and routing. `--create-session` creates a separate Session for the target Agent.+- `--fork-session <id>` creates a new Agent Session from that source Session's native backend context; use it for alternate paths that need the source context but should not mutate the source Session.- For another Agent doing an independent trial, comparison, delegation, or specialist subtask, use `vibe agent run --agent <agent-name> --create-session --message ...`.- Use `vibe agent run --agent <agent-name> --session-id ... --message ...` only to continue that same Session. Reuse the current session id only with Agents whose `Backend` matches `{current_agent_backend}`; otherwise use `--create-session`.+- With `--fork-session`, pass `--agent`, `--model`, or `--reasoning-effort` only as forked-Session overrides, and only when the requested Agent backend matches the source Session backend.- `--async` changes waiting behavior, not session identity: synchronous waits for the result; async runs in the background and is inspected later with `vibe runs`.- Create or update Agents only when it captures a reusable role, reduces repeated prompting, or makes a long-running Harness more reliable.diff --git a/docs/CLI.md b/docs/CLI.mdindex 81fb49931..871a3aee4 100644--- a/docs/CLI.md+++ b/docs/CLI.md@@ -204,10 +204,19 @@ a scheduled task definition.```bashvibe agent run --agent release-reviewer --message 'Review the latest deployment result.'vibe agent run --async --session-id sesk8m4q2p7x --message 'The export finished. Share the summary.'+vibe agent run --async --fork-session sesk8m4q2p7x --message 'Explore this alternate fix from the current context.'vibe agent run --async --session-id sesworker123 --callback-session-id sescaller456 --message 'Run the delegated investigation.'vibe agent run --async --create-session --deliver-key slack::channel::C999 --agent release-reviewer --message 'Post the deployment summary.'```+Use `--fork-session <session-id>` when a new Agent Session should branch from+an existing Session's native backend context instead of starting blank. The new+Session keeps the source backend. `--agent`, `--model`, and+`--reasoning-effort` can override the forked Session only when the Agent backend+stays the same; a cross-backend fork is rejected. Do not combine+`--fork-session` with `--session-id`, `--create-session`, `--deliver-key`, or+`--post-to`.+Use `--callback-session-id` when an async run should send its final result textback into a caller Session as a follow-up Agent message. The callback isindependent from ordinary delivery: if the target run also posts to its IM scope,diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.mdindex 75f0a8c09..4e03aa95c 100644--- a/docs/CLI_ZH.md+++ b/docs/CLI_ZH.md@@ -185,10 +185,18 @@ vibe task remove <task-id>```bashvibe agent run --agent release-reviewer --message 'Review the latest deployment result.'vibe agent run --async --session-id sesk8m4q2p7x --message 'The export finished. Share the summary.'+vibe agent run --async --fork-session sesk8m4q2p7x --message 'Explore this alternate fix from the current context.'vibe agent run --async --session-id sesworker123 --callback-session-id sescaller456 --message 'Run the delegated investigation.'vibe agent run --async --create-session --deliver-key slack::channel::C999 --agent release-reviewer --message 'Post the deployment summary.'```+当一个新 Agent Session 需要从现有 Session 的 native backend 上下文分叉,而不是空白开始时,+使用 `--fork-session <session-id>`。新 Session 会保持源 Session 的 backend。+只有 backend 不变时,才可以通过 `--agent`、`--model`、`--reasoning-effort`+覆盖 fork 后 Session 的 Agent、模型或推理强度;跨 backend fork 会被拒绝。+不要把 `--fork-session` 和 `--session-id`、`--create-session`、`--deliver-key`+或 `--post-to` 混用。+当异步 run 的最终结果文本需要回到调用方 Session 时,使用`--callback-session-id`。这个 callback 与普通投递相互独立:即使目标 run 已经把结果发到了自己的 IM scope,调用方 Session 仍然会收到结果并触发一次跟进diff --git a/docs/COMMANDS.md b/docs/COMMANDS.mdindex 7d133c04c..ba02ec46c 100644--- a/docs/COMMANDS.md+++ b/docs/COMMANDS.md@@ -817,15 +817,18 @@ point back to this command.### `vibe agent run````bash-vibe agent run (--session-id <session_id> | --create-session)? (--message <text> | --message-file <file>) [options]+vibe agent run (--session-id <session_id> | --create-session | --fork-session <session_id>)? (--message <text> | --message-file <file>) [options]```Important options:- `--agent`- `--session-id`+- `--fork-session`- `--create-session`- `--deliver-key`+- `--model`+- `--reasoning-effort`- `--async`- `--message`- `--message-file`@@ -834,6 +837,14 @@ If neither `--session-id` nor `--create-session` is provided, the run uses aprivate no-delivery session and is best suited for sub-agent style calls.`--deliver-key` is only meaningful with `--create-session`.+`--fork-session <session_id>` creates a new Agent Session by forking the source+Session's native backend context. It is for alternate investigations or+delegated work that should keep the source context without mutating the source+Session. Forks keep the same backend as the source; `--agent`, `--model`, and+`--reasoning-effort` may override the forked Session only when the backend does+not change. Do not combine `--fork-session` with `--session-id`,+`--create-session`, `--deliver-key`, or `--post-to`.+## 5.4 `vibe runs``vibe runs` inspects concrete Agent Run records produced by tasks, watches, ordiff --git a/docs/COMMANDS_ZH.md b/docs/COMMANDS_ZH.mdindex 9196267b5..66ab5aefe 100644--- a/docs/COMMANDS_ZH.md+++ b/docs/COMMANDS_ZH.md@@ -793,15 +793,18 @@ vibe agent models --backend opencode --provider deepseek### `vibe agent run````bash-vibe agent run (--session-id <session_id> | --create-session)? (--message <文本> | --message-file <文件>) [options]+vibe agent run (--session-id <session_id> | --create-session | --fork-session <session_id>)? (--message <文本> | --message-file <文件>) [options]```重要参数:- `--agent`- `--session-id`+- `--fork-session`- `--create-session`- `--deliver-key`+- `--model`+- `--reasoning-effort`- `--async`- `--message`- `--message-file`@@ -810,6 +813,13 @@ vibe agent run (--session-id <session_id> | --create-session)? (--message <文no-delivery session,更适合 sub-agent 调用。`--deliver-key` 只和`--create-session` 搭配使用。+`--fork-session <session_id>` 会基于源 Session 的 native backend 上下文创建一个新的+Agent Session,适合在保留上下文的同时做分支调查或委派工作,而不修改源 Session。+fork 会保持源 Session 的 backend;只有 backend 不变时,`--agent`、`--model`+和 `--reasoning-effort` 才能覆盖 fork 后 Session 的 Agent、模型或推理强度。+不要把 `--fork-session` 和 `--session-id`、`--create-session`、`--deliver-key`+或 `--post-to` 混用。+## 5.4 `vibe runs``vibe runs` 用来查看由 task、watch 或直接 Agent Run 产生的一次次实际执行记录。diff --git a/skills/use-avibe/SKILL.md b/skills/use-avibe/SKILL.mdindex 1052081e7..657072016 100644--- a/skills/use-avibe/SKILL.md+++ b/skills/use-avibe/SKILL.md@@ -772,6 +772,7 @@ Preferred CLI shape:- one-shot direct run: `vibe agent run --agent '<agent-name>' --message '...'`- one-shot async run: `vibe agent run --async --session-id '<session-id>' --message '...'`+- fork a Session for an alternate path: `vibe agent run --fork-session '<source-session-id>' --message '...'`- delegated async run that reports back: `vibe agent run --async --session-id '<target-session-id>' --callback-session-id '<caller-session-id>' --message '...'`- recurring task: `vibe task add --session-id '<session-id>' --cron '<expr>' --message '...'`- one-off task: `vibe task add --session-id '<session-id>' --at '<ISO-8601>' --message '...'`@@ -792,6 +793,9 @@ Delivery controls (apply to `vibe agent run --create-session`, `vibe task add`,- `--message` and `--message-file` are the current user-message flags for task, watch, and agent-run commands- `vibe task add` stores the message template and creates Agent Runs when the time trigger fires- `vibe agent run --async` queues one Agent Run immediately without storing a task definition+- `--fork-session` creates a new Agent Session by forking the source Session's native backend context. Use it when work should branch from an existing context without mutating that source Session.+- fork overrides are intentionally narrow: `--agent`, `--model`, and `--reasoning-effort` can override the forked Session only if the backend stays the same; cross-backend forks are rejected.+- do not combine `--fork-session` with `--session-id`, `--create-session`, `--deliver-key`, or `--post-to`.- `--callback-session-id` on an async Agent Run sends the final result text back into the caller Session as a follow-up Agent message; it is independent from `--post-to` and `--deliver-key`- `vibe watch add` uses `--message` as the instruction template for the Agent Run created after the waiter reaches a reportable statediff --git a/skills/use-vibe-remote/SKILL.md b/skills/use-vibe-remote/SKILL.mdindex 5c9dff62c..9f26aa323 100644--- a/skills/use-vibe-remote/SKILL.md+++ b/skills/use-vibe-remote/SKILL.md@@ -772,6 +772,7 @@ Preferred CLI shape:- one-shot direct run: `vibe agent run --agent '<agent-name>' --message '...'`- one-shot async run: `vibe agent run --async --session-id '<session-id>' --message '...'`+- fork a Session for an alternate path: `vibe agent run --fork-session '<source-session-id>' --message '...'`- recurring task: `vibe task add --session-id '<session-id>' --cron '<expr>' --message '...'`- one-off task: `vibe task add --session-id '<session-id>' --at '<ISO-8601>' --message '...'`- immediate rerun: `vibe task run <id>`@@ -791,6 +792,9 @@ Delivery controls (apply to `vibe agent run --create-session`, `vibe task add`,- `--message` and `--message-file` are the current user-message flags for task, watch, and agent-run commands- `vibe task add` stores the message template and creates Agent Runs when the time trigger fires- `vibe agent run --async` queues one Agent Run immediately without storing a task definition+- `--fork-session` creates a new Agent Session by forking the source Session's native backend context. Use it when work should branch from an existing context without mutating that source Session.+- fork overrides are intentionally narrow: `--agent`, `--model`, and `--reasoning-effort` can override the forked Session only if the backend stays the same; cross-backend forks are rejected.+- do not combine `--fork-session` with `--session-id`, `--create-session`, `--deliver-key`, or `--post-to`.- `vibe watch add` uses `--message` as the instruction template for the Agent Run created after the waiter reaches a reportable stateLegacy compatibility:diff --git a/tests/test_cli_task_command.py b/tests/test_cli_task_command.pyindex 668640f00..250c07e36 100644--- a/tests/test_cli_task_command.py+++ b/tests/test_cli_task_command.py@@ -263,6 +263,21 @@ def test_hook_send_help_includes_examples_and_threadless_guidance(capsys) -> Nonassert "vibe agent run --async --session-id sesk8m4q2p7x" in captured.out+def test_agent_run_help_includes_fork_session_guidance(capsys) -> None:+ parser = cli.build_parser()++ with pytest.raises(SystemExit) as exc:+ parser.parse_args(["agent", "run", "--help"])++ assert exc.value.code == 0+ captured = capsys.readouterr()+ assert "--fork-session FORK_SESSION" in captured.out+ assert "Use --fork-session to create a new Session by forking an existing Session's native backend context." in captured.out+ assert "Forks keep the same backend as the source Session." in captured.out+ assert "vibe agent run --async --fork-session sesk8m4q2p7x" in captured.out+ assert "Do not combine --fork-session with --session-id, --create-session, --create-session-per-run, --deliver-key, or --post-to." in captured.out++def test_task_add_parse_error_is_structured_json(capsys) -> None:parser = cli.build_parser()diff --git a/tests/test_reply_enhancer_platform.py b/tests/test_reply_enhancer_platform.pyindex 34a33f644..bb7b73979 100644--- a/tests/test_reply_enhancer_platform.py+++ b/tests/test_reply_enhancer_platform.py@@ -332,11 +332,14 @@ class ReplyEnhancerPlatformTests(unittest.IsolatedAsyncioTestCase):self.assertIn("### Choosing the right Harness shape", prompt)self.assertIn("| Independent Agent delegation | `vibe agent run --create-session` |", prompt)self.assertIn("| Same-session follow-up | `vibe agent run --session-id ...` |", prompt)+ self.assertIn("| Branch from existing Session context | `vibe agent run --fork-session ...` |", prompt)self.assertIn("`vibe task add` creates a time-triggered saved Agent message", prompt)self.assertIn("`vibe watch add` creates a managed monitor", prompt)self.assertIn("product signals, business events, files, logs, CI/reviews/deploys", prompt)self.assertIn("vibe agent run --async --callback-session-id sesk8m4q2p7x", prompt)self.assertIn("final result text should return to this caller Session", prompt)+ self.assertIn("vibe agent run --fork-session <source-session-id> --message ...", prompt)+ self.assertIn("Forks keep the source Session backend", prompt)self.assertIn("`--post-to` changes the delivery target, not the session scope. Use `--post-to channel` when the session should stay thread-scoped but the follow-up message should be posted to the parent channel.",prompt,@@ -357,9 +360,11 @@ class ReplyEnhancerPlatformTests(unittest.IsolatedAsyncioTestCase):self.assertIn("Use the `Agent Name` value exactly as listed in shell commands", prompt)self.assertIn("`--session-id <id>` resumes that exact Agent Session and its transcript, backend identity, Show Page, and routing", prompt)self.assertIn("`--create-session` creates a separate Session for the target Agent", prompt)+ self.assertIn("`--fork-session <id>` creates a new Agent Session from that source Session's native backend context", prompt)self.assertIn("vibe agent run --agent <agent-name> --create-session --message ...", prompt)self.assertIn("vibe agent run --agent <agent-name> --session-id ... --message ...", prompt)self.assertIn("Reuse the current session id only with Agents whose `Backend` matches `codex`; otherwise use `--create-session`", prompt)+ self.assertIn("With `--fork-session`, pass `--agent`, `--model`, or `--reasoning-effort` only as forked-Session overrides", prompt)self.assertIn("`--async` changes waiting behavior, not session identity", prompt)self.assertIn("inspected later with `vibe runs`", prompt)self.assertNotIn("--create-session-per-run", prompt)diff --git a/vibe/cli.py b/vibe/cli.pyindex 074d24227..9ed3e3d9c 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -621,6 +621,29 @@ def _watch_add_examples_text() -> str:)+def _agent_run_examples_text() -> str:+ return dedent(+ """\+ Session target:+ Use --session-id to continue an existing Agent Session.+ Use --create-session to start a new blank Session.+ Use --fork-session to create a new Session by forking an existing Session's native backend context.++ Forking:+ --fork-session <session-id> creates a new Avibe Agent Session and asks the native backend to fork the source native session on the first turn.+ Forks keep the same backend as the source Session. Passing --agent is allowed only when that Agent uses the same backend.+ --agent, --model, and --reasoning-effort may override the forked Session's Agent/model/effort.+ Do not combine --fork-session with --session-id, --create-session, --create-session-per-run, --deliver-key, or --post-to.++ Examples:+ vibe agent run --agent release-reviewer --message 'Review the latest deployment result.'+ vibe agent run --async --session-id sesk8m4q2p7x --message 'The export finished. Share the summary.'+ vibe agent run --async --fork-session sesk8m4q2p7x --message 'Explore this alternate fix from the current context.'+ vibe agent run --fork-session sesk8m4q2p7x --agent reviewer --model gpt-5.4 --reasoning-effort high --message 'Review the forked context.'+ """+ )++def _add_hidden_task_alias(task_subparsers, alias: str, parser) -> None:alias_parser = task_subparsers.add_parser(alias,@@ -5883,6 +5906,7 @@ def build_parser():"run",help="Run an Avibe Agent",description="Run an Avibe Agent turn. Use --async to queue it as a background run.",+ epilog=_agent_run_examples_text(),formatter_class=argparse.RawDescriptionHelpFormatter,error_help_command="vibe agent run --help",)