o is a workspace for Ollama's agent harness: the agent core, the tools, and the agent TUI, in one place you can change and test without touching the ollama repo.
Most of the code is adapted from the ollama repo, with imports rewritten to
github.com/ParthSareen/o.
| Path | Contains |
|---|---|
agent/ |
The harness core: session, events, tool registry, approvals, compactor, skills |
agent/tools/ |
bash, file, web, and skill tools |
cmd/o/ |
The entry point of the agent TUI (package main) |
cmd/tui/chat/ |
The interactive chat UI (bubbletea) |
cmd/launch/ |
A trimmed shim: the spinner and the types that the TUI uses. The integration runners (claude, codex, …) are not included. |
cmd/config/, cmd/internal/ |
Small support packages for the TUI |
sessionstore/ |
SQLite-backed session persistence. Only in o. |
.agents/skills/ |
Project skills. update-o runs the build/test/install/ship loop for the CLI. |
api/, auth/, envconfig/, format/, progress/, version/, logutil/ |
Public support packages |
internal/ |
Internal support packages. These must be copies; you cannot import them across modules. |
types/model/ |
Model capabilities and names |
You need a local Ollama server. Start it with ollama serve.
Install:
go install ./cmd/oUse:
o [model] # start the interactive TUI (uses the last model)
o [model] "prompt" # print the answer and exit
o --headless <model> # headless, prompt from args or stdin
o --resume # resume the most recent session
o --resume-id <id> # resume a session by ID
o --list # list saved sessions
o --name <text> [model] # start a new session with a nameFlags: --system, --allow-all-tools (no approval prompts), --auto
(on by default: a review model grades tool calls; --auto=false falls back
to approval prompts), --review-model (grading model for auto mode),
--no-tools, --multimodal, --context-window, --headless, --pipe,
--resume, --resume-id, --list, --name. Run o --help for the full
usage text, which includes rules for headless use by agents.
--pipe speaks a machine-readable NDJSON protocol over stdio (prompt/cancel
commands in, the full agent event stream out) for UI frontends.
It implies --allow-all-tools unless you set the flag explicitly; pass
--auto there for review-model grading.
Auto mode is the default starting mode. It sits between review mode (prompt
for every tool call via --auto=false) and --allow-all-tools (run
everything). Tool calls that would prompt go to a
review model instead of the terminal: reads and known read-only shell
commands skip the model entirely, and everything else is graded with the
same decision contract as the Codex Guardian setup in ollama's compat proxy
(risk level, user authorization, outcome, rationale). Denials carry the
reviewer's rationale back to the agent, critical-risk calls are denied even
when the reviewer allows, and anything malformed fails closed — in the TUI a
failed review falls back to the human prompt, headless runs deny.
--review-model (or O_REVIEW_MODEL) picks the grading model; the default
selected uses the session model. In the TUI, shift+tab cycles
auto → full access → review. Every model-graded call leaves a ⟳ auto review line in the transcript (outcome, risk, duration; ctrl+o expands
the rationale), and headless runs log the same line to stderr.
Slash commands: /sessions selects a session to resume, /resume [<id|name>] resumes the most recent or a matching session, /name [set <text>] shows or sets the session name, /help lists all commands.
Keys:
| Key | Action |
|---|---|
ctrl+t |
Open nvim in the working directory. O_NVIM overrides the command. |
ctrl+g |
Open the nvim diff viewer (nvim -c DiffviewOpen). O_NVIM_DIFF overrides the command. |
ctrl+o |
Toggle inline tool output, thinking text, and auto-review rationales. |
Both keys suspend the TUI and come back when you exit nvim. They need nvim in
PATH. /nvim and /diffview do the same but are hidden: they are not in
/help or in the completions.
Background shell tasks (background=true) are killed when the session exits,
so they cannot outlive o; use watchy for processes that should persist.
Recurring checks should use the poll tool instead of background sleep loops:
each tick re-runs the command once, and output that differs from the previous
tick interrupts an in-flight run as a background-task notice (unchanged output
is suppressed). Polls stop when the session exits.
The chat renders markdown: headings, code fences, tables, emphasis, links, images (alt text only), lists, blockquotes, and horizontal rules.
o saves sessions to ~/.o/sessions.db (SQLite). Each session gets a UUID,
and o appends the messages after each run.
A session can have a name. Set it with --name at launch or with
/name set <text> in the TUI. o --list prints the ID, Name, Model, and
Title of each session; sessions without a name show (unnamed). o upgrades
an old database when it opens it; no manual step is necessary.
Headless runs print their saved session ID on stderr as session: <id>
(background-task logs carry the line too), and o --resume-id <id> --headless "follow-up" continues that conversation — the session's model is
reused, so an agent can follow up on a finished child without restating it.
o always runs against its own ollama server on port 11433, started through
watchy (OLLAMA_DEBUG=1, loopback only) — even when a shared server already
listens on 11434. These rules apply:
- o starts the server only if watchy and the
ollamabinary are installed. - o never stops or replaces a server that runs.
- o reuses a dedicated server from an earlier launch.
- If you set
OLLAMA_HOST, o uses it as it is. - If o cannot start a dedicated server, it falls back to a shared server on 11434 when one answers.
To manage the dedicated server:
watchy logs o-ollama-11433
watchy stop o-ollama-11433o adds these on top of the ollama code:
sessionstore/— session persistence, only in o.cmd/o/main.go— new runner. It does the same aslaunchInteractiveModelwithout thecmdpackage plumbing.cmd/o/headless.go— headless mode, only in o.cmd/o/model_helpers.go— simplified copies ofshowOrPullModel,ensureCloudStub, andinferThinkingOption. The:cloudsuggestion flow is removed.cmd/launch/agent_shim.go— hand-maintained types that the TUI uses, instead of the fullcmd/launchpackage.cmd/tui/chat/— session names (--name,/name), the nvim keys (ctrl+t,ctrl+g), and the extended markdown renderer.patches/17295-syntax-highlighting.diff— the changes from ollama/ollama#17295 (syntax highlighting in fenced code blocks), applied in-tree. When the PR merges upstream, delete the patch.
License: MIT (same as ollama).