Skill: /btw — Substrate-Native Session Aside
Consumer for the cog_fork_session CogOS kernel primitive. Forks the current session into a child, runs a parenthetical tangent in the child, then returns control to the parent.
MUST call cog_fork_session with:
parent_session_id= current session IDoverlay.role.role= "btw-aside"overlay.context.clear_parent_context= false (child inherits parent context at fork point)
MUST NOT start the aside until the fork is confirmed (child_session_id returned). MUST surface any fork error verbatim — do not silently proceed without a fork.
When to use
- User types
/btwmid-conversation - User says "by the way, ..." and the aside is substantive enough to be worth tracking separately
- User asks to "fork this" or "spin off" a tangent
- User wants to explore a counterfactual without losing the main thread
When NOT to use
- One-sentence questions — just answer inline, no fork needed
- When
cog_fork_sessionis unavailable (kernel not running, MCP not wired) — fall through to answering inline and note the limitation - When the user explicitly wants to stay in the same thread
Preconditions
Check whether cog_fork_session is directly in your tool surface. Depending on kernel version it may be deferred plumbing rather than eagerly exposed. Before falling back inline, check for cog_tool_search + cog_tool_invoke (the porcelain pair): if present, use cog_tool_search to confirm cog_fork_session exists in the deferred catalog, then invoke it via cog_tool_invoke(name="cog_fork_session", args={...}) with the same arguments documented below. Only fall through to answering inline if neither cog_fork_session nor the cog_tool_search/cog_tool_invoke pair is available.
Procedure
Step 1 — Identify the current session ID
The current session ID should be known from the session registration at session start (the session_id set when cog_register_session was called). If not known, use cog_list_sessions to find the most recently-heartbeated session.
Step 2 — Fork the session
Call cog_fork_session with these args, either directly (if it's in the eager surface) or via cog_tool_invoke(name="cog_fork_session", args={...}) (if only the deferred porcelain pair is present):
{
"parent_session_id": "<current-session-id>",
"overlay": {
"role": {
"role": "btw-aside"
},
"context": {
"clear_parent_context": false
}
}
}
This produces a child_session_id. The child inherits the parent's context at the fork point and runs with role btw-aside.
Step 3 — Complete the aside
Address the user's /btw question or tangent. The aside is logically bounded to the child context. Keep responses focused on the aside topic.
When the aside is complete, say something like: "Aside complete. Returning to the main thread." This signals the return to parent context.
Step 4 — Mark the child session ended (optional)
If the kernel session lifecycle matters, call cog_end_session with session_id = the child_session_id to mark it ended cleanly.
Step 5 — Resume the parent session
Return to the parent thread by continuing the prior conversation where it left off. The parent's context was preserved at the fork point.
Merge-back pattern (optional)
If the aside produced information worth carrying back to the parent thread:
- Summarize the aside findings in one paragraph.
- Ingest the summary via
cog_ingest(if the kernel supports it) so it appears in the parent's foveal context. - Reference the aside's
child_session_idin the summary for lineage traceability.
Error handling
| Error | Action |
|---|---|
cog_fork_session not in tool surface AND cog_tool_search/cog_tool_invoke unavailable |
Answer inline; note that /btw requires the cogos-kernel MCP server |
cog_fork_session absent from eager surface but cog_tool_search/cog_tool_invoke present |
Route through cog_tool_invoke(name="cog_fork_session", args={...}) (see Step 2) |
| Parent session not found (404) | Use cog_register_session to register the current session first, then retry |
| Cross-workspace fork (501) | Not supported on all kernel versions; answer inline |
| Fork succeeds but child registration fails | Proceed with aside anyway; note the registry miss in the response |
Example invocation
User: /btw — how does the fork primitive interact with session identity?
- Fork with
overlay.role.role = "btw-aside". - Answer the question in the child context.
- Say "Aside complete. Returning to the main thread."
- Resume the parent thread.
Kernel dependencies
cog_fork_session— the fork primitivecog_list_sessions— for session ID discoverycog_end_session(optional) — for clean child lifecycle
Notes
- The fork primitive also underlies parallel exploration tracks, agent spawning, and time-travel via self-fork —
/btwis the simplest application. - Lineage queries beyond a direct parent/child relationship require direct registry inspection via
cog_list_sessions+ event reads, on kernel versions where dedicated ancestor/descendant lookup tools aren't shipped.