docs: align runtime references with current behavior
This commit is contained in:
1 parent
0c7dbc6aac
commit
dfb3843b4d
4 files changed
+58
-47
No files matched your search
+1
-1
@@ -41,4 +41,4 @@ Built-in skills live in `nanobot/skills/` (markdown + YAML frontmatter format).
|
||||
|
||||
`nanobot/agent/memory.py` owns the memory journal `memory/history.jsonl`; ordinary entries are appended under a lock, without explicit fsync. Full journal rewrites use `atomic_write_lines` with its default file and directory fsync. Preserve that atomic replacement path rather than truncating the live journal in place.
|
||||
|
||||
Conversation history belongs to `nanobot/session/manager.py`. Session saves use atomic replacement, with fsync controlled by the caller; the default is `False`, while durable shutdown and other explicit durability paths request `True`. Preserve the distinction between atomic visibility and crash durability, and retain locks and explicit fsync on paths that require them.
|
||||
Conversation history is stored in `sessions.sqlite3`. `SessionState` (`nanobot/session/state.py`) owns runtime access; `SqliteSessionStore` (`nanobot/session/sqlite_store.py`) commits changes in SQLite transactions using WAL and `PRAGMA synchronous = FULL` on every connection. `SessionManager.save()` is for offline administrative snapshots and has no per-save fsync option. Keep runtime mutations behind the async owner and preserve transaction boundaries and stale-generation checks.
|
||||
+38
-41
@@ -1,6 +1,6 @@
|
||||
# My Tool
|
||||
|
||||
This page is for operators configuring the agent's runtime self-inspection tool. It describes what the agent can read or change at runtime, and what it saves. It is not a user preference store: scratchpad values last only through the next conversation turn.
|
||||
This page is for operators configuring the agent's runtime self-inspection tool. It describes what the agent can read or change at runtime, and what it saves. Scratchpad values survive across turns until the agent runtime restarts; they are shared by sessions using that runtime, not private per-session storage or durable preferences.
|
||||
|
||||
## Why You Need It
|
||||
|
||||
@@ -8,9 +8,9 @@ Normal tools let the agent operate on the outside world (read/write files, searc
|
||||
|
||||
My tool fills this gap. With it, the agent can:
|
||||
|
||||
- **Know who it is**: What model am I using? Where is my workspace? What is my per-turn iteration limit?
|
||||
- **Adapt on the fly**: Complex task? Expand the context window. Simple chat? Switch to a faster model.
|
||||
- **Remember across turns**: Store notes in your scratchpad that persist into the next conversation turn.
|
||||
- **Inspect the current request**: What model am I using? Which project can I access? What is my per-turn iteration limit?
|
||||
- **Tune runtime settings**: Adjust the iteration limit or select a configured model preset for the session's next turn when writes are enabled.
|
||||
- **Keep temporary notes**: Store non-sensitive scratchpad values across turns, without relying on them surviving a restart.
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -33,25 +33,26 @@ Most modifications are held in memory only. `model_preset` is the exception: it
|
||||
|
||||
## check — Check "my" current state
|
||||
|
||||
Without parameters, returns a key config overview:
|
||||
Without a key, returns an overview of inspectable runtime settings. Example values:
|
||||
|
||||
```text
|
||||
my(action="check")
|
||||
# → max_iterations: 40
|
||||
# context_window_tokens: 200000
|
||||
# model: 'anthropic/claude-sonnet-4-6'
|
||||
# workspace: PosixPath('/tmp/workspace')
|
||||
# model_preset: 'deep'
|
||||
# workspace: PosixPath('/tmp/agent-workspace')
|
||||
# workspace_sandbox: {...}
|
||||
# provider_retry_mode: 'standard'
|
||||
# max_tool_result_chars: 16000
|
||||
# _last_usage: {'prompt_tokens': 45000, 'completion_tokens': 8000}
|
||||
# Note: prompt_tokens is cumulative across all turns, not current context window occupancy.
|
||||
# ...
|
||||
```
|
||||
|
||||
With a key parameter, drill into a specific config:
|
||||
|
||||
```text
|
||||
my(action="check", key="_last_usage.prompt_tokens")
|
||||
# → How many prompt tokens I've used so far
|
||||
my(action="check", key="workspace_sandbox.workspace_root")
|
||||
# → Current project path
|
||||
|
||||
my(action="check", key="model")
|
||||
# → What model I'm currently running on
|
||||
@@ -67,16 +68,18 @@ my(action="check", key="web_config.enable")
|
||||
| "What model are you using?" | `check("model")` |
|
||||
| "Which model preset is active?" | `check("model_preset")` |
|
||||
| "What is the per-turn iteration limit?" | `check("max_iterations")` |
|
||||
| "How many tokens has this conversation used?" | `check("_last_usage")` — cumulative across all turns |
|
||||
| "Where is your working directory?" | `check("workspace")` |
|
||||
| "Show me your full config" | `check()` |
|
||||
| "Are there any subagents running?" | `check("subagents")` — shows phase, iteration, elapsed time, tool events |
|
||||
| "What is the context-window capacity?" | `check("context_window_tokens")` — capacity, not current usage or remaining space |
|
||||
| "Which project is active?" | `check("workspace_sandbox.workspace_root")` |
|
||||
| "Is file access restricted to the project?" | `check("workspace_sandbox.restrict_to_workspace")` |
|
||||
| "Show inspectable runtime settings" | `check()` |
|
||||
|
||||
`workspace` is a legacy display of the agent workspace, not the current project or an access grant. Use `workspace_sandbox` for the active project and file restriction. `exec_config` separately reports shell sandbox settings; shell binds do not grant file tools access.
|
||||
|
||||
---
|
||||
|
||||
## set — Runtime tuning
|
||||
|
||||
Changes do not require a restart. `model_preset` is saved for the current session and applies to its next turn; other writable runtime tuning takes effect immediately. Direct `model` and `context_window_tokens` writes are rejected during an active session because those setters change the shared instance default. Configure a named preset for model or context-window changes instead.
|
||||
Changes do not require a restart. `model_preset` is saved for the current session and applies to its next turn. Other writable settings are updated in memory; changing the iteration limit does not extend an already-running agent loop. Direct `model` and `context_window_tokens` writes are rejected during an active session because those setters change the shared instance default. Configure a named preset for model or context-window changes instead.
|
||||
|
||||
```text
|
||||
my(action="set", key="max_iterations", value=80)
|
||||
@@ -86,13 +89,13 @@ my(action="set", key="model_preset", value="fast")
|
||||
# → Use a configured model preset for this session's next turn
|
||||
```
|
||||
|
||||
You can also store custom state in your scratchpad:
|
||||
You can also store temporary, non-sensitive state in your scratchpad. Values remain available across turns until the runtime restarts, and are shared by its sessions:
|
||||
|
||||
```text
|
||||
my(action="set", key="current_project", value="nanobot")
|
||||
my(action="set", key="user_style_preference", value="concise")
|
||||
my(action="set", key="task_focus", value="documentation")
|
||||
my(action="set", key="response_style", value="concise")
|
||||
my(action="set", key="task_complexity", value="high")
|
||||
# → These values persist into the next conversation turn
|
||||
# → These notes survive across turns, but not a runtime restart
|
||||
```
|
||||
|
||||
### Protected parameters
|
||||
@@ -101,12 +104,12 @@ These parameters have type and range validation — invalid values are rejected:
|
||||
|
||||
| Parameter | Type | Range | Purpose |
|
||||
|-----------|------|-------|---------|
|
||||
| `max_iterations` | int | 1–100 | Max tool calls per conversation turn |
|
||||
| `max_iterations` | int | 1–100 | Max model/tool iterations per agent run |
|
||||
| `context_window_tokens` | int | 4,096–1,000,000 | Instance default; during a session, select through a preset |
|
||||
| `model` | str | non-empty | Instance default; during a session, select through a preset |
|
||||
| `model_preset` | str | configured preset name | Current session's preset for its next turn |
|
||||
|
||||
Other parameters (e.g. `workspace`, `provider_retry_mode`, `max_tool_result_chars`) can be set freely, as long as the value is JSON-safe.
|
||||
`provider_retry_mode` and `max_tool_result_chars` must match their existing value types. Setting `workspace` changes only the legacy display string, not the active project, shell directory, or file permissions. Unknown top-level keys store JSON-safe scratchpad values rather than creating runtime settings. Nested configuration fields cannot be changed through `my`.
|
||||
|
||||
---
|
||||
|
||||
@@ -141,36 +144,30 @@ User: "Why aren't you searching the web?"
|
||||
Agent: Let me check my web config.
|
||||
→ my(action="check", key="web_config.enable")
|
||||
# → False
|
||||
Agent: Web search is disabled — please set web.enable: true in your config.
|
||||
Agent: Web search is disabled — please set tools.web.enable: true in your config.
|
||||
```
|
||||
|
||||
### "Token budget management"
|
||||
### "Context capacity"
|
||||
|
||||
```text
|
||||
Agent: Let me check how much budget I have left.
|
||||
→ my(action="check", key="_last_usage")
|
||||
# → {"prompt_tokens": 45000, "completion_tokens": 8000}
|
||||
Agent: I've used ~53k tokens total so far. I'll keep my remaining replies concise.
|
||||
Agent: Let me check the context-window capacity.
|
||||
→ my(action="check", key="context_window_tokens")
|
||||
# → context_window_tokens: 200000
|
||||
```
|
||||
|
||||
This is the configured capacity, not current occupancy, remaining space, or cumulative token usage. `my` does not expose `_last_usage`. For context and per-round usage, see the [WebUI activity and context indicators](./webui.md#activity-and-context-usage).
|
||||
|
||||
### "Subagent monitoring"
|
||||
|
||||
Subagent snapshots include only tasks created by the current session. This scope also applies to `subagents._task_statuses.<task_id>` and nested fields. Without a current session key, direct subagent checks return an error and the full overview contains no tasks. Completed tasks are removed; this is not a result archive.
|
||||
Use the separate `subagent` tool, not `my`. To list the current session's live tasks or inspect a known task ID:
|
||||
|
||||
```text
|
||||
Agent: Let me check on the background tasks.
|
||||
→ my(action="check", key="subagents")
|
||||
# → 2 subagent(s):
|
||||
# [task-1] 'Code review'
|
||||
# phase: running, iteration: 5, elapsed: 12.3s
|
||||
# tools: read(✓), grep(✓)
|
||||
# usage: {'prompt_tokens': 8000, 'completion_tokens': 1200}
|
||||
# [task-2] 'Write tests'
|
||||
# phase: pending, iteration: 0, elapsed: 0.2s
|
||||
# tools: none
|
||||
Agent: The code review is progressing well. The test task hasn't started yet.
|
||||
subagent(action="check")
|
||||
subagent(action="check", task_id="<task-id>")
|
||||
```
|
||||
|
||||
Only tasks owned by the current session are accessible. A known task ID can retrieve retained results after completion; finished tasks leave the live list. Checks without a current session identity fail. Background results arrive automatically, so avoid repeated polling.
|
||||
|
||||
---
|
||||
|
||||
## Safety Mechanisms
|
||||
@@ -185,7 +182,7 @@ Cannot be checked or modified — fully hidden:
|
||||
|----------|-----------|--------|
|
||||
| Core infrastructure | `bus`, `provider`, `_running` | Changes would crash the system |
|
||||
| Tool registry | `tools` | Must not remove its own tools |
|
||||
| Subsystems | `runner`, `sessions`, `consolidator`, etc. | Affects other users/sessions |
|
||||
| Subsystems | `runner`, `sessions`, `consolidator`, `subagents`, etc. | Use dedicated tools instead of inspecting internal managers |
|
||||
| Sensitive data | `_mcp_servers`, `_pending_queues`, etc. | Contains credentials and message routing |
|
||||
| Security boundaries | `restrict_to_workspace`, `channels_config` | Bypassing would violate isolation |
|
||||
| Python internals | `__class__`, `__dict__`, etc. | Prevents sandbox escape |
|
||||
@@ -196,7 +193,7 @@ Can be checked but not set:
|
||||
|
||||
| Category | Attributes | Reason |
|
||||
|----------|-----------|--------|
|
||||
| Subagent manager | `subagents` | Observable, but replacing breaks the system |
|
||||
| Workspace access | `workspace_sandbox` | Shows the active project and file restriction; cannot change access |
|
||||
| Execution config | `exec_config` | Can check sandbox/enable status, cannot change it |
|
||||
| Web config | `web_config` | Can check enable status, cannot change it |
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ description: Inspect or troubleshoot the agent's runtime state, adjust runtime s
|
||||
## Constraints
|
||||
|
||||
- `model_preset` is saved for the current session; other modifications are in-memory only
|
||||
- Scratchpad values survive across turns until the agent runtime restarts and are shared by its sessions; do not treat them as private per-session storage.
|
||||
- Use `my(action="check", key="workspace_sandbox")` for the current project and file restriction. `workspace` is only a legacy agent-directory display.
|
||||
- Direct `model` and `context_window_tokens` writes are rejected during active sessions because they would change the shared instance default. Use a configured `model_preset` instead.
|
||||
- Protected params have type/range validation: `max_iterations` (1–100), `context_window_tokens` (4096–1M), `model` (non-empty str)
|
||||
- If `tools.my.allow_set` is false, check only
|
||||
@@ -65,8 +67,8 @@ description: Inspect or troubleshoot the agent's runtime state, adjust runtime s
|
||||
|
||||
| Need | Use | Persists? |
|
||||
|------|-----|-----------|
|
||||
| Per-session temp state | `my(action="set", key="...", value=...)` | No |
|
||||
| Temporary runtime notes | `my(action="set", key="...", value=...)` | Across turns, not restarts |
|
||||
| Long-term facts | Memory skill (`MEMORY.md`, `USER.md`) | Yes |
|
||||
| Permanent config change | Edit config file | Yes |
|
||||
|
||||
**Rule of thumb:** Tomorrow? Memory. This turn only? My.
|
||||
**Rule of thumb:** Durable facts? Memory. Temporary runtime notes? My.
|
||||
@@ -8,7 +8,7 @@ Concrete scenarios showing when and how to use the my tool effectively.
|
||||
```
|
||||
→ my(action="check", key="web_config.enable")
|
||||
→ False
|
||||
→ "Web search is disabled. Add web.enable: true to your config to enable it."
|
||||
→ "Web search is disabled. Set tools.web.enable: true in your config to enable it."
|
||||
```
|
||||
|
||||
### "Why did you stop?"
|
||||
@@ -26,6 +26,16 @@ Concrete scenarios showing when and how to use the my tool effectively.
|
||||
→ 'deep'
|
||||
```
|
||||
|
||||
### "Which project can you access?"
|
||||
```
|
||||
→ my(action="check", key="workspace_sandbox.workspace_root")
|
||||
→ workspace_sandbox.workspace_root: '/projects/nanobot'
|
||||
→ my(action="check", key="workspace_sandbox.restrict_to_workspace")
|
||||
→ workspace_sandbox.restrict_to_workspace: True
|
||||
```
|
||||
|
||||
`workspace` is a legacy agent-directory display. Setting it does not switch the project or change file permissions.
|
||||
|
||||
## Adaptive Behavior
|
||||
|
||||
### Large codebase analysis
|
||||
@@ -44,9 +54,11 @@ Concrete scenarios showing when and how to use the my tool effectively.
|
||||
→ "Selected the fast preset for this session's next turn."
|
||||
```
|
||||
|
||||
## Cross-Turn Memory
|
||||
## Temporary Runtime Notes
|
||||
|
||||
### Remembering user preferences
|
||||
Scratchpad values survive across turns until the runtime restarts and are shared by its sessions. Use them only for non-sensitive temporary notes, not private per-session state or durable preferences.
|
||||
|
||||
### Keeping a temporary style preference
|
||||
```
|
||||
# Turn 1: user says "keep it brief"
|
||||
→ my(action="set", key="user_style", value="concise")
|
||||
|
||||
Reference in new issue
Block a user