Replace switch statement with rdwrHandler map. Each command is a
function value in agentCtlHandlers — easy to extend, test individually,
and introspect.
/tools — lists loaded tools
/tool_load X — loads a tool by name
System prompt updated to instruct the agent to use ctl for tool
management instead of writing to a tools file.
/models now lists available models for the agent's backend via ctl.
One fewer file in the agent namespace. The root-level models file
(all backends) remains unchanged.
The ctl file is now a Request handler: write a command, read the
response. Commands with no args return current state:
/model → prints current model
/agent → prints current profile
/cwd → prints working directory
/name → prints agent name
/model X → switches model, returns new model
/compact → compacts, returns 'ok'
o ctl now uses 'ollie-9p rdwr' to get the response.
This enables /model (no args) to show the current model from
any frontend.
The slash prefix in prompts now routes directly to the agent's ctl
file. No special-cased commands in the agent — the ctl handler is the
single command surface:
/stop, /compact, /clear, /model X, /inject X, /agent X, /cwd X
New ctl commands:
inject <text> — overwrites any pending inject (replaces /i and /irw)
agent <name> — switch agent profile (moved from commands.go)
Agent methods added: Compact(), Clear(), SwitchProfile() — called by
the ctl handler, testable independently.
HandleCommand is now a thin trampoline: strip /, run 'o ctl <rest>'.
commands.go reduced from 155 to 50 lines.
REPL: / → o ctl, !q/!quit → exit TUI.
The sandbox escape mechanism is a bypass, not privilege elevation.
The old name caused the agent to confuse it with sudo.
- elevate/ → bypass/ (package, types, tests)
- elevate_notify.go → bypass_notify.go
- Namespace: /elevate → /bypass, session/*/elevate → session/*/bypass
- Tool arg: "elevated" → "bypass"
- Env: OLLIE_ELEVATE_SOCKET → OLLIE_BYPASS_SOCKET
- File: elevate-policy.yaml → bypass-policy.yaml
- All docs, prompts, and scripts updated
- fifo.in + fifo.out → single fifo (write enqueues, read dequeues)
- cost + usage + ctxsz → single stats (key=value lines)
- Remove connection (no consumers, heartbeat handles it)
- Remove dead prevPrompt field and write (prompt.prev gone from spec)
- Clean AGENT_FILES: remove state, context, tail (all already absent
from spec, were only in the tab-completion list)
chat — strips [[[...]]] markers and source fences at the byte level.
Partial lines pass through immediately for true streaming. Terminals
and text editors use this.
chat.raw — full block-structured stream with markers and fences.
GUIs that parse blocks (KDE, web) use this.
The TUI no longer pipes through grep (which was line-buffering and
killing char-by-char streaming since Aug 4).
The stripMarkers state machine processes each chunk from the server:
- Complete lines starting with [[[ and ending with ]]] → dropped
- Fence lines (```...) → dropped (open toggles in-fence state)
- Partial lines (no trailing \n) → always emitted immediately
- Everything else → passed through
- Export ID, Uname, Ctx, Cancel, Proc, Keeper, Remote as struct fields
(set-once at creation, not raced during agent loop)
- Keep mutex-protected accessors only for Name, ToolsConn, IsPaused
which are read/written concurrently
- Extract buildAgent() shared helper used by both CreateAgent and
restoreMultiAgentSession — eliminates ~100 lines of duplicated
orchestration (tool server setup, prompt layers, runtime, backend)
- Paused sessions skip tool server entirely during restore (minimal
agent with just history)
- Update fs/session_node.go delegators for exported fields
- 1638 → 1523 lines (-115)
The previous commit (3b83b9d) replaced globalRootState with
ctx.Root.Data.(*RootState), but ctx.Root is nil inside closures
captured by BuildTree (Root is set *after* the tree is built).
Fix: add RootState field to HandlerCtx and create it before BuildTree
so all closures capture the live pointer directly.
toolsrv:
- Merge rpc.go into conn.go (wire types already there)
- Merge tools.go + discover.go into registry.go
- Merge accessors.go into server.go
- 4 files eliminated
fs:
- HandlerCtx.Context now carries the session context (set via
sessionBindings Applier). Previously it was the daemon context
which never cancels — handlers checking ctx.Done() now properly
detect session kill/pause.
- Session-scoped blocking handlers (streamAgentChat, blockAgentStateWait)
merge session context with per-read timeout via mergeCtx(). A session
kill now immediately unblocks readers without waiting for the 5s timeout.
- Remove redundant manual AfterFunc in blockAgentStateWait.
session:
- Remove unused _ string parameter from WaitEvent
The agent always talks to a *Conn (never a *Server directly).
Replace the Runner interface with the concrete type throughout:
- Runtime.ToolServer is now *toolsrv.Conn
- BuildRuntime takes *toolsrv.Conn
- session.Config, SessionInfra, InfraConfig use *toolsrv.Conn
- All inline type assertions in agent.go deleted — methods called
directly on *Conn (SetEnv, SetCWD, Close, Detach, ListDetachedRaw,
SignalDetached, GetDetachedOutput, DismissDetached, SetAllowTools,
SetOnToolsChanged, Ping, ToolRegistryRevision)
- Added Conn.ToolRegistryRevision() that returns 0 (remote connections
don't support revision tracking; use push-based OnToolsChanged instead)
- Deleted the Runner interface and its test
- Renamed LoadToolOnRunner → LoadToolOnConn
FormatEvent now takes primitive string arguments instead of agent.Event.
This fixes the dependency direction - format/ should be a leaf package
that agent/, session/, and fs/ depend on, not the other way around.
- Move FormatEvent to format/ package for reuse by both live handler
and replay
- Move LoadConfig to agent/ package where it belongs
- Remove log validator (was noisy, not essential)
- Update replay to use FormatEvent for consistent output format
- Update kde submodule with GUI streaming fix
The event handler was emitting [[[end]]] to close an assistant block
without first closing an open streaming fence (code block). This left
the log in a state where a [[[call:...]]] block appeared nested inside
an unclosed assistant block, triggering a log structure violation.
Now the call and default cases close streamingFence (like the tool case
already did) before writing the [[[end]]] marker.
- Extract all [[[block]]] formatting constants/helpers into format/format.go
(EndTag, RoleDelim, ToolDelim, CallDelim, BlockHeader, ParseBlockHeader, IsEndMarker)
- Replace switch/case ctl dispatchers in fs/handlers.go with generic
ctlDispatch() from new fs/ctl.go
- Add LogValidator state machine to AgentLog enforcing:
- Every [[[block]]] MUST have an [[[end]]] marker
- Blocks SHALL NOT be nested
- Streaming line buffering across partial writes
- Fatal failure on first violation with line-number reporting
- UnclosedAtTeardown() for session/agent teardown checks
- Fix kde/kate ollie_ghost compile: stripPrefixEcho signature mismatch
- Removed from fs/spec.go: prompt.prev, state, offset, context, tail
- Removed handlers: readAgentPromptPrev, readAgentState, readAgentOffset, readAgentContext, readAgentTail
- statewait still exists but now has an inline read handler
- 5 files out of the namespace; 18 agent-level files remaining
- Reduces each agent dir by 5 entries
- HandlerCtx now embeds context.Context for per-operation cancellation/deadline
- Reverted fsedsl signatures back to simple (ctx Ctx) since context is embedded
- requestGenerate handler uses ctx instead of context.Background()
- cmdInject propagates its context parameter instead of using Background
- Delete agent/complete.go (110 lines) and its requestComplete handler
- Remove /complete 9P file from fs/spec.go
- Update KDE kate plugin to build the completion prompt inline and call
ollie-9p rdwr generate instead of ollie-9p rdwr complete
- StripCompletionNoise and stripPrefixEcho moved into C++ helpers
- Removed 19 redundant GID("agent") calls from leaf nodes and subdirectories
- Root DirNode now sets GID once; all descendants inherit via fsedsl resolver
Remove no-op cases that did nothing but carry stale comments:
- ctl: backend (selection via cfg instead)
- ctl: skills (handled elsewhere)
- cfg: backend, model
prompts: remove session operational model (9P/DBus prompt blocks)
compact and clear were dead-code comments in writeAgentCtl. Wire them
through agent.HandleCommand so they actually execute. Fix context: use
ctx.Session.Ctx() instead of context.Background() for proper lifecycle
cancellation.
Delete session_9p.md and session_dbus.md — no longer referenced.
- CreateEmpty(name, remote) now spawns remote toolsrv when remote is set
- requestSessionNew parses remote= argument
- Add Session.SetRemote() method
- Update kde submodule
After the fs/session refactor, NewEventHandler was defined but never
called. Agents created via session restore or CreateAgent had nil
output handlers, so emit() was a no-op and the chat stream stayed empty.
- Add Agent.SetOutput() to allow setting the event handler post-creation
- Wire up SetOutput(NewEventHandler(al)) in fs/newroot.go for restored sessions
- Wire up SetOutput(NewEventHandler(al)) in fs/handlers.go for new agents
- Also includes expanded UsageStats fields and TaskState persistence
session/persist.go:
- New multi-agent format: PersistedSession with []PersistedAgent
- PersistSession saves ALL agents, not just first
- RestoreAllSessions returns []RestoredSession with []RestoredAgent
- Backward compatible: restores legacy single-agent format
fs/persist.go:
- Thin wrapper that creates AgentLogs for each restored agent
- Delegates to session.PersistSession/RestoreAllSessions
agent/agent.go:
- Added Messages() to get conversation history
- Added Usage() to get token/cost stats
agent/history.go:
- Added RestoreHistoryFromMessages for multi-agent restore
session/session.go:
- Added Remote() getter
The Adapter was pure boilerplate - every method just delegated to the
package-level generic function. Removing it simplifies the API:
- Delete fsedsl/adapter.go
- Update fs/adapter.go to call fsedsl functions directly
- Update README.md to document direct usage
- Remove adapter tests (now redundant)
Coverage remains at 94.8%.