Bläddra i källkod

docs: add session management guide

Alvin Unreal 3 månader sedan
förälder
incheckning
cc17d1e7cf
3 ändrade filer med 155 tillägg och 26 borttagningar
  1. 4 6
      README.md
  2. 6 20
      docs/configuration.md
  3. 145 0
      docs/session-management.md

+ 4 - 6
README.md

@@ -67,9 +67,6 @@ The default generated configuration looks like this:
 {
   "$schema": "https://unpkg.com/oh-my-opencode-slim@latest/oh-my-opencode-slim.schema.json",
   "preset": "openai",
-  "sessionManager": {
-    "maxSessionsPerAgent": 2
-  },
   "presets": {
     "openai": {
       "orchestrator": { "model": "openai/gpt-5.4", "variant": "high", "skills": ["*"], "mcps": ["*", "!context7"] },
@@ -83,9 +80,9 @@ The default generated configuration looks like this:
 }
 ```
 
-`sessionManager.maxSessionsPerAgent` controls how many resumable child sessions
-the orchestrator remembers per specialist type inside the current parent
-session.
+Session management is enabled by default even though it is not shown in the
+starter config. See **[Session Management](docs/session-management.md)** if you
+want to customize how many resumable child-agent sessions are remembered.
 
 ### For Alternative Providers
 
@@ -480,6 +477,7 @@ Use this section as a map: start with installation, then jump to features, confi
 | **[Council](docs/council.md)** | Run multiple models in parallel and synthesize a single answer with `@council` |
 | **[Interview](docs/interview.md)** | Turn rough ideas into a structured markdown spec through a browser-based Q&A flow |
 | **[Multiplexer Integration](docs/multiplexer-integration.md)** | Watch agents work live in Tmux or Zellij panes |
+| **[Session Management](docs/session-management.md)** | Reuse recent child-agent sessions with short aliases instead of starting over |
 | **[Todo Continuation](docs/todo-continuation.md)** | Auto-continue orchestrator sessions with cooldowns and safety checks |
 | **[Preset Switching](docs/preset-switching.md)** | Switch agent model presets at runtime with `/preset` |
 | **[Codemap](docs/codemap.md)** | Generate hierarchical codemaps to understand large codebases faster |

+ 6 - 20
docs/configuration.md

@@ -108,7 +108,7 @@ Presets can also be switched at runtime without restarting using the `/preset` c
 | `tmux.enabled` | boolean | `false` | Legacy alias for `multiplexer.type = "tmux"` |
 | `tmux.layout` | string | `"main-vertical"` | Legacy alias for `multiplexer.layout` |
 | `tmux.main_pane_size` | number | `60` | Legacy alias for `multiplexer.main_pane_size` |
-| `sessionManager.maxSessionsPerAgent` | integer | `2` | Maximum remembered resumable child sessions per specialist type in the current orchestrator session (1–10) |
+| `sessionManager.maxSessionsPerAgent` | integer | `2` | Maximum remembered resumable child sessions per specialist type in the current orchestrator session (1–10). See [Session Management](session-management.md) |
 | `disabled_mcps` | string[] | `[]` | MCP server IDs to disable globally |
 | `fallback.enabled` | boolean | `false` | Enable model failover on timeout/error |
 | `fallback.timeoutMs` | number | `15000` | Time before aborting and trying next model |
@@ -171,26 +171,12 @@ automatically.
 > `"oh-my-opencode-slim@1.0.1"`) are the true version lock. Those stay pinned
 > regardless of `autoUpdate`.
 
-### Session Manager
+### Session Management
 
-The session manager is enabled by default. It keeps a small in-memory working
-set of resumable child sessions for orchestrator-managed delegations, scoped to
-the current parent orchestrator session.
-
-```jsonc
-{
-  "sessionManager": {
-    "maxSessionsPerAgent": 2
-  }
-}
-```
-
-Notes:
-
-- Only orchestrator-managed `task` delegations participate
-- Manual `@agent` calls do not reuse this registry
-- Sessions are kept in memory only and disappear on restart
-- When a remembered session is missing, the next delegation falls back to a fresh child session
+Session management is enabled by default and does not need to be present in the
+starter config. Add `sessionManager` only if you want to tune how many resumable
+child-agent sessions are remembered. See [Session Management](session-management.md)
+for the concept, defaults, and examples.
 
 ### Agent Display Names
 

+ 145 - 0
docs/session-management.md

@@ -0,0 +1,145 @@
+# Session Management
+
+Session management lets the orchestrator keep track of recent delegated child
+sessions so follow-up work can continue in the right specialist context instead
+of starting from scratch every time.
+
+It is enabled by default. You do not need to add anything to your config unless
+you want to change how many sessions are remembered.
+
+---
+
+## Why It Exists
+
+Delegation works best when specialists can continue a thread they already
+understand:
+
+- Explorer can continue investigating the same part of the codebase.
+- Oracle can keep reviewing the same architecture/debugging thread.
+- Fixer can continue a scoped implementation or test update.
+- Librarian can continue the same documentation/API research.
+
+Without session management, follow-up delegations usually create fresh child
+sessions. That works, but the specialist may need repeated context. With session
+management, the orchestrator can reuse recent child sessions when it makes sense.
+
+---
+
+## How It Feels in Practice
+
+When a child task runs, the plugin remembers it under a short alias such as:
+
+```text
+exp-1
+ora-1
+fix-2
+```
+
+The orchestrator sees a compact reminder in its system context, for example:
+
+```text
+### Resumable Sessions
+explorer: exp-1 Search routing files
+oracle: ora-1 Review auth architecture
+```
+
+On a related follow-up, the orchestrator can reuse that session instead of
+launching a fresh one. If the remembered child session no longer exists, the
+plugin drops the stale entry and falls back to a new session automatically.
+
+---
+
+## Scope and Safety
+
+Session management is intentionally narrow:
+
+- It only applies to orchestrator-managed `task` delegations.
+- It is scoped to the current parent orchestrator session.
+- It is in-memory only and disappears when OpenCode/plugin state restarts.
+- It does not change manual `@agent` calls.
+- It keeps only a small number of recent sessions per specialist type.
+- Missing or deleted child sessions are cleaned up automatically.
+
+This keeps the feature useful for continuity without turning child sessions into
+long-lived global state.
+
+---
+
+## Default Behavior
+
+By default, the plugin remembers **2 recent child sessions per specialist type**.
+
+That means the generated starter config can stay clean:
+
+```jsonc
+{
+  "preset": "openai",
+  "presets": {
+    "openai": {
+      "orchestrator": { "model": "openai/gpt-5.4" },
+      "explorer": { "model": "openai/gpt-5.4-mini" },
+      "fixer": { "model": "openai/gpt-5.4-mini" }
+    }
+  }
+}
+```
+
+Session management still works because the runtime falls back to the built-in
+default.
+
+---
+
+## Configuration
+
+Only add `sessionManager` if you want to change the default limit:
+
+```jsonc
+{
+  "sessionManager": {
+    "maxSessionsPerAgent": 2
+  }
+}
+```
+
+### `sessionManager.maxSessionsPerAgent`
+
+| Type | Default | Range | Meaning |
+|------|---------|-------|---------|
+| integer | `2` | `1`–`10` | Number of recent resumable child sessions remembered per specialist type in the current parent session |
+
+Use a higher value if you often run several parallel threads per specialist. Use
+a lower value if you want fewer aliases in the orchestrator context.
+
+---
+
+## When To Tune It
+
+Most users should leave the default alone.
+
+Consider changing it when:
+
+- You frequently run multiple independent Explorer/Oracle/Fixer threads in one
+  long orchestrator session.
+- You want the orchestrator prompt to stay smaller and prefer only one remembered
+  thread per specialist.
+- You are debugging session reuse behavior and want a predictable small window.
+
+Example with a smaller memory window:
+
+```jsonc
+{
+  "sessionManager": {
+    "maxSessionsPerAgent": 1
+  }
+}
+```
+
+Example with a larger memory window:
+
+```jsonc
+{
+  "sessionManager": {
+    "maxSessionsPerAgent": 4
+  }
+}
+```