light Plan · ox CLI · agent experience · 2026-10-21
Meet agents where they type: fixing ox's command map
282 failed invocations from the last 30 days (Sep 22 – Oct 22), every one replayed against v0.24.2 in a sandbox.
Summary
81 of the 282 failures weren't agent mistakes. ox caused them.
Decision
Approve 3 PRs: telemetry privacy now, then smarter frictionax matching, then the map, flags, and guards.
Biggest risk
Auto-execute runs the wrong command. AUTO only when the verb is preserved; the corpus test locks every outcome.
Ship first
Friction events send raw argv: home paths, org names, team IDs, session text, a full prompt. No redactor is configured.
Where it leaks
Four leaks between what an agent types and a working command. Hover one.
Aox taught it · 38 Bshell didn't split · 35 Cexact match only · 8 Dnonsense fuzzy · 4 shapes
ox names commands that fail
session log --role … is ox's own hint, but cobra rejects the flags before the handler runs. Same for ox ledger sync and ox conventions; 6 more stale references found in source.
Fix: make them reachable, correct the strings, test every reference.
zsh passes "plan list" as one argument
Agents loop over command names; zsh doesn't split $var. frictionax already suggests the exact fix and doesn't run it.
Fix: if the joined argument resolves to a real path, split it and run.
Catalog entries miss on trailing args
auth → login works bare, fails as auth --help. ledgers → ledger targets a command that doesn't exist.
Fix: longest-prefix matching, args carried through; validate every target.
Fuzzy picks unrelated commands
mcp and doc → gc (reclones repositories). api → pr, pat → pet.
Fix: edit distance scaled to word length.
Map changes
New entries: AUTO only when the verb is preserved.
| Agent typed | ox runs / suggests | Mode | Events |
|---|---|---|---|
plan show <slug> | plan view <slug> | AUTO | 15 |
agent [<id>] status | session status | AUTO | 5 |
ledger · ledger status · ledger sync | status · sync | AUTO | 5 |
<group> --list · <group> help | <group> list (where it exists) · <group> --help | AUTO | 6 |
skill · skill list | skills · skills list | AUTO | 4 |
agent <id> session score · agent score | session score | AUTO | 4 |
agent heartbeat --agent-id <id> | agent <id> heartbeat | AUTO | 2 |
conventions | agent team-ctx | AUTO | 2 |
discussion · session start · agent session-list | conversation · agent session start · session list | AUTO | 3 |
update | upgrade | ASK | 4 |
cart · bulletin · distill · memory · session trace | "not enabled for this account" | HONEST | 20 |
ledgers → ledger · agent list · daemon stop | retarget dead target; delete entries real commands now shadow | CLEAN | — |
AUTO same verb, runsASK verb changes or mutatesNot mapped: repo api mcp token env (~15, no clear target)
Flag vocabulary
Agents assume siblings share flags. They don't, yet.
| Command | --limit | --since | --until | --all | --text |
|---|---|---|---|---|---|
plan list | 19 | add | add | 5 | · |
murmur list | 5 | ✓ | add | · | · |
session list | ✓ | 5 | add | ✓ | · |
conversation list | ✓ | ✓ | 4 | · | ✓ |
conversation transcript | 3 | · | · | · | ✓ |
plan view · status · query | · | · | · | · | 6 |
✓ has itn requested, missingadd contract fills it Contract
Every list: --limit --json. Time-ordered lists add --since --until. A tree walk enforces it.
Everywhere
--text means "not JSON". One catalog rewrite, skipped where a command owns the flag.
Suggest only
--repo → repo: in the query · --title → page title or --topic · --input → positional.
Guards
Five tests make each class of fix stick.
Corpus
Every anonymized shape from this export has an expected outcome.
closes B C D + new entries References
Every ox … in ox's strings and shipped skills resolves, flags included.
closes A Catalog
Every target resolves; no entry shadowed by a real command.
closes C Vocabulary
The list-flag contract, walked over the whole tree.
closes flag drift Privacy
No flag value or positional reaches a friction event.
closes raw argv
Each is proven red-first: break the behavior, watch the specific case fail, restore.
Sequence
Three PRs. Privacy ships alone and first.
| Decided (reversible) | ★ Default | Alternative |
|---|---|---|
| Where prefix matching lives | ★ frictionax | ox regex workaround |
| When to auto-execute | ★ same verb, not destructive | any high-confidence match |
| Flag drift | ★ add the real flags | catalog aliases only |
| Server catalog overlay (never loads in the CLI today) | ★ embedded catalog is the source | wire the overlay now |
Implementation notes
Data and method
- Export: 282 events (147 unknown-command, 135 unknown-flag); 277 agent, 5 human; Claude Code 184, Codex 61, Amp 31, Pi 1; clients v0.10.1–v0.23.0.
- Normalized to 175 anonymized argv shapes (IDs, paths, slugs, free text replaced), then replayed against a v0.24.2 build with a throwaway
HOME,OX_NO_DAEMON=1,DO_NOT_TRACK=1,SAGEOX_FRICTION=false, endpointhttp://127.0.0.1:9, non-git cwd. - Buckets (first rule wins): flag drift 83 · no alias 63 · ox taught it 38 · word-split 35 · works now 27 · gated off 20 · catalog miss 8 · probes 8.
- Word-split signature: the error names a multi-word command, e.g.
unknown command "plan list" for "ox"; they mostly arrive in sub-second bursts (a loop over command names). - Probes (
bogus,--nonexistent-flag,skills install x) are agents testing error handling; excluded from targets, kept in the corpus as "stays an error". - This page carries counts and command shapes only — no names, paths, org names, or slugs from the export.
PR 1 — ox: friction events stop carrying raw input
cmd/ox/friction.goinitFrictionpasses noWithRedactor, so frictionax uses its no-op redactor andEvent.Inputis the joined argv (truncated at 500). Observed in the export: absolute home paths with OS usernames, customer org/repo names, team IDs,session log --contenttext, and a full multi-line user prompt.- After
handleFriction, overwriteresult.Event.Inputfrom the real argv slice: keep tokens that are command-path words in the cobra tree and flag names (drop=value); replace every other token with<arg>, collapsing runs. Apply the same token rule to quoted names inErrorMsg(unknown command "conversation show cnv_…"). Add frictionax's secrets redactor as defense in depth. - Daemon
RecordFromIPC(internal/daemon/friction.go): apply the conservative whitespace-token rule too, so a payload from any client is scrubbed before it leaves the machine. - Forward the existing
FrictionEvent.Suggestion(set it fromresult.Suggestion.Corrected, redacted) throughdaemon.FrictionPayload; ox drops it today, so the dashboard cannot tell a corrected event from a dead end. - Test (red-first): drive
executeWithFrictionRecoverywith argv containing a synthetic home path, free text, and a fake team ID; capture viasendFrictionEventTo's injectable socket; assert none of the values appear. Remove the overwrite → fails. - Private-owner follow-up (generic): retention of already-collected raw inputs.
PR 2 — frictionax (public library, sageox-owned)
catalog.goLookupCommand: today exact match on the normalized string (positionals, then sorted flags). Add longest positional-prefix match: try exact, then shrinking prefixes of the positionals; on a hit, the target replaces the prefix and the remaining positionals and flags are appended.auth status(exact entry →status) must beatauth(→login).levenshtein.go: fixedmaxDistancelets 3-letter words reach unrelated commands. Use distance ≤1 for words ≤4 characters, ≤2 otherwise, and no suggestion when the distance is half the word or more.FrictionEvent.Outcome(auto|suggested|none), set inHandle; populateSuggestionthere too.- Table-driven tests for prefix precedence, remainder carry-through, short-word thresholds. Tag a release.
PR 3 — ox: reachability, strings, map, flags, guards
- Dispatcher reachability.
cmd/ox/agent.goregisters hidden persistent flags for manually parsed agent flags (--title,--file, …) and reinjects them.--role,--content,--stdin,--tool-name,--tool-inputare missing, soox agent <id> session log …fails at cobra parse (the replay showsunknown flag: --role). Unit tests callrunAgentSessionLogdirectly and miss it. Register and reinject them; add an E2E test throughrootCmdfor each documentedsession logform. - Stale strings.
ox ledger sync→ox syncininternal/daemon/status_display.goandcmd/ox/agent_prime.go;ox conventions→ox agent team-ctxinclaude-plugin/skills/ox/SKILL.md. The prototype scan also found references that fail on v0.24.2:ox plan --render,ox plan view --open,ox redaction verify,ox doctor --run-autofix-now,ox session stop --adapter,ox agent prime --user(some may be comments; the reference test decides). - Reference test.
cmd/ox/command_refs_test.go: parse non-test Go files withgo/parserand scan string literals (not comments), plus shipped skill markdown, for quoted/backtickedox …; resolve the path withrootCmd.Findwith all feature flags on, plus the agent dispatcher's subcommand table; check flags withLookupon local, inherited, andagentCmdpersistent sets. A small allowlist covers deliberate placeholders. - Word-split.
cmd/ox/main.go, beforeapplyCatalogTokenRewrites: ifargs[0]contains whitespace andstrings.Fields(args[0])resolves to a non-root command, splice the fields in. Emit a_correctedhint: zsh doesn't split$var; use an array or${=var}. - Catalog (
cmd/ox/default_catalog.json): entries from the Map changes view. Generic<group> help→<group> --helpis a regex entry.--listis not: a blind regex turnsguide --listintoguide list, whichguidereads as a topic name. Handle it in ox beside the word-split step: an unknown--<word>becomes<word>only when that subcommand exists. Retargetledgers; deleteagent listanddaemon stop(real commands now resolve first); retargetagent ls→agent list. - Catalog validity test. Every non-regex target resolves via
rootCmd.Find; no pattern resolves as a real command; regex entries are checked through corpus examples. - Flags.
plan list:--limit --all --since --until.murmur list:--limitcanonical,--lastkept hidden.session list:--since --until,--windowas a hidden alias.conversation list:--until.conversation transcript:--limit(cue count). - Token rewrites.
cmd/ox/flag_rewrites.gorewrites only=-qualified patterns. Add an explicit"rewrite": truefor bare boolean flags so--text→--json=falseand--full-json→--jsonrun;commandAcceptsLongFlagalready skips commands that own the flag. frictionax ignores the extra field. - Vocabulary test.
cmd/ox/flag_vocabulary_test.gowalksrootCmd: each leaf namedlisthas--limitand--json; leaves annotated time-ordered (sessions, plans, murmurs, conversations) also have--sinceand--until.daemon list,skills list,team listare not time-ordered. - Gated commands. Keep a registry of feature-gated commands in
syncFeatureGatedCommands; inexecuteWithFrictionRecovery, an unknown command whose name is in the registry prints "ox <name>isn't enabled for this account" instead of "unknown command". - Corpus test.
cmd/ox/testdata/friction-corpus.jsonstores the anonymized shapes with an expected outcome (resolves · auto → target · suggests target · gated message · stays an error). Assert withrootCmd.FindplusfrictionEngine.Handleon synthesized cobra errors — no command executes, so no side effects. Red-first: delete theplan showentry → that shape fails. - Bump frictionax; add a human-focused entry to
cmd/ox/release_notes.md.
Collisions and gotchas
cmd/ox/agent.goandcmd/ox/agent_session.gowere touched by two other workspaces recently; open PR #959 touchesagent_session.goand #757 touchescmd/ox/plan.go(both last updated Aug–Sep). Murmur before editing; rebase late.- Agent-dispatcher errors (
unknown command or invalid agent_id: ls) get no suggestion today even though^agent ls$is in the catalog; the corpus must cover dispatcher shapes. - Prefix matching changes what existing entries match. Run the corpus before and after the frictionax bump and diff the outcomes.
- The CLI passes
WithCachePathbut builds no collector, so a server-synced catalog is never loaded, andUpdateCatalogreplaces rather than merges. No cache file exists on a dev machine running the daemon. Fix the misleading comment ininitFriction; leave overlay wiring for later. - Replay and classification scripts live in
.context/friction-scripts/(not committed). Rerun them on the next export to measure.
Verification
- Per PR:
make lint,make test; the new guard tests shown red-first in the PR body. - Deterministic gate for
/goal: corpus test green, reference test with zero unresolved, privacy test green. - Outcome check: on the next 30-day export, "still fails on latest" drops for every bucket except "no clear target".

