Skip to content

tole v0.9.0

Choose a tag to compare

@ajianaz ajianaz released this 29 Oct 05:42
· 41 commits to main since this release
a55a868

Context compaction, global session index, command allow/deny, failover chain, child-agent handoff.

Includes the 0.8.2 hardening patch (see CHANGELOG.md [0.8.2]), which was never tagged or published on its own.

Added

  • Context compaction, wired (#440, 2/2): chat, resume and mission compact between turns once a prompt reaches --compact-at (default 0.8; config compact_at) of the model's context window. The window is TOLE_CONTEXT_WINDOW / config context_window, else what the provider's /models reports for the session's model (context_length, context_window, max_context_length, max_model_len, max_input_tokens, top_provider.context_length) — looked up lazily, only once a prompt passes 8k tokens, at most once per process; with neither, compaction stays off and says so once. A failed summary call is reported and the session continues uncompacted. --no-compaction / config no_compaction turns it off; tole status lists each compaction; tole config check shows the effective values and their sources.
  • Context compaction, core (#440, 1/2): tole_core::compaction. compact() summarizes the settled turns before the kept tail with the session's provider and commits ONE compaction entry (summary, first kept entry, compacted count, prompt size before) together with the summary call's usage row — atomic, append-only, the transcript is never rewritten. view() is what the provider sees: the transcript as is, or the latest summary (inside the untrusted-content fence used for tool results, introduced as a record rather than instructions) followed by the kept tail; the turn loop sends view(). due() compares the last call made AFTER the last compaction against Policy { window, at, keep_turns }, so the summary call never re-triggers it. Inactive until the CLI wiring (window resolution, --compact-at, --no-compaction, mission/chat/resume hooks, tole status) lands.
  • Global session index (#439): every face that starts a session (run, chat, mission, serve/ACP/MCP) appends one line to $CODECORA_HOME/tole/sessions-index.jsonl (default ~/.codecora/tole/, owner-only, append-only, a bad line is skipped): id, absolute session file, cwd, face, start time — never prompt text. tole sessions --all lists sessions from every project newest first, with their cwd and first-prompt preview read from the session file (gone files are hidden); --grep <text> filters on prompt, name or cwd. tole resume <id> for a session of another project refuses with the exact command to run there (cd <project> && tole resume <id>): resuming from here would apply this directory's workspace jail, config and trust to that session. TOLE_NO_SESSION_INDEX=1 turns recording off.
  • Command-level allow/deny patterns (#438): run_command:<argv pattern> in --allow / config allow matches run_command calls by the argv the tool executes (same splitter, no shell, so ; never chains a second command): one glob per argument, a final lone * = any further arguments, the program compared literally for an allow (run_command:* allows nothing). A leading ! makes any pattern a deny that wins over every allow and over --yes; a deny compares the program by file name, case-insensitively, without .exe/.cmd/.bat/.com (/bin/RM, rm.exe vs rm *). Fail closed: while a run_command deny is configured, a command runs unattended only when an explicit run_command: allow names it (a bare run_command allow or --yes is not enough) and never when its program is a known wrapper (sh, bash, env, sudo, xargs, ...); everything else asks the human (refused where nobody can be asked). Denies travel with allow lists, a child agent always inherits its parent's denies, and a child's command pattern must be covered argument by argument by a parent pattern (list_covers: under a parent command deny only a parent run_command: allow covers it; a child wildcard only by the same glob or a lone *). In AllowlistApprover::deny_only (no allows), a run_command: deny refuses every run_command call. tole_core::approval::pattern_verdict is the one evaluation both approvers use.
  • --trust workspace (#437): read_only plus write_file / edit_file through a path guard. The tools are jailed to the workspace root (canonicalized, so ../ and symlinks cannot escape), and the guard keeps files another tool may later execute prompting: any dot-component (.git/hooks, .envrc, .vscode/, .tole/, .github/), build and task files (build.rs, Cargo.toml, Makefile, package.json, pyproject.toml, SKILL.md, AGENTS.md, ...) and scripts (.sh, .ps1, ...). delete_file (Destructive) and run_command keep prompting; the preset needs an explicit --workspace (or config workspace) and refuses a home or filesystem root. Not a sandbox: ordinary source files stay writable. The guard checks the RESOLVED target the tool will write (relative to the canonical jail root, symlinks followed; Windows trailing dots/spaces normalized, 8.3 short names refused), never the raw path text. It is a pattern suffix (write_file@workspace) matched by tole_core::approval::pattern_allows, so --allow and child agents use it too. API: Tool::approval_target (default None; decorators must forward it) and ToolRequest::target are new.
  • web_search backends beyond the fleet contract (#436): TOLE_WEB_SEARCH_METHOD (GET default, or POST with the JSON body {"query", "limit"}), TOLE_WEB_SEARCH_HEADERS (Name=Value pairs, ${VAR} expanded from the environment, sent only to the backend; transport headers and line breaks refused; errors never echo a value) and TOLE_WEB_SEARCH_FIELDS (wire=backend, e.g. snippet=description,results=items). A malformed value fails startup instead of dropping the tool. API: tole_core::web::WebSearchTool::from_env now returns Result<Option<Self>, String>; WebSearchTool::new(url) and from_lookup are new.
  • User config (#433): $CODECORA_HOME/tole/config.toml (default ~/.codecora/tole/config.toml) holds global defaults with the project config's keys and validation. Precedence is flag > env > project config > user config > default, key by key; it needs no trust record, --no-config ignores it too, and tole config check shows both files and the winning layer per key ((user config)).
  • TOLE_SKILL (#434): preload skill files from the environment (SKILL.md paths, separated like PATH) — the env layer of the skill key, so --skill still replaces it and it replaces the config's skill list. Server faces refuse it like --skill, and the refusal names the variable.
  • Code review with cora (#422, 3/3): when cora mcp (cora ≥ 0.19) is attached, the system prompt of tole run / tole chat names the agent-as-reviewer flow — mcp_cora_cora_review_prepare with the diff, the model's own judgement, then mcp_cora_cora_review_finalize with the same diff and its findings — so "review this change" uses cora's deterministic checks and verdict without an LLM key in cora. Absent in plan mode and without the review tools.
  • Supported sibling versions (#422): cora ≥ 0.19.0 and uteke ≥ 0.21.1, kept in one place (tole_cli::ecosystem). tole doctor prints an ecosystem: section reporting each binary as supported, too old (with its upgrade command) or not installed; it never blocks, since both are optional.
  • Provider failover chain (#209): failover::FailoverProvider retries a step on the next provider of an ordered chain when the active one is unavailable (connection failure, timeout, dropped stream, HTTP 5xx or 429); request errors (401/403/404/400, malformed responses) fail loud and never fail over. The answering provider stays active and the primary is retried after a cooldown. Each step records the route under tole_route in its usage row (durable, auditable); rows holding only tole's own keys are not counted as provider steps. Wired into every session face through TOLE_FALLBACK_BASE_URL / TOLE_FALLBACK_API_KEY / TOLE_FALLBACK_MODEL (a reserve without its own key is refused; the primary's key is never sent to another host). A stream that breaks after part of the answer was already shown live does not fail over (no duplicated output); a reserve that fails before the cooldown ends wraps back to the primary; and after a failover only the last provider's error decides the turn loop's transient retry, so an earlier timeout no longer makes a reserve's 401 look retryable.
  • Child-agent handoff schema and verify gate (#383): tole_core::handoff defines the typed handoff document (role explore / implement / verify / fix, artifact references by path and rev, verification evidence), strict validation of the model-authored input (workspace-relative paths, option-safe refs, bounded fields), the close gate (an implement/fix child without passing verification is Unverified / VerifyFailed, never closed silently) and the prompt for the follow-up fix child. agent_start takes role and consumes (artifact references the child reads itself), a role child gets a handoff_submit tool, and agent_poll reports the gate and a ready-made fix_prompt (the parent decides whether to start the fix child; nothing is spawned automatically). Design and anti-goals (no DAG engine) in docs/child-agents-handoff.md.
  • Sibling change notices, core (#380): sibling_watch tracks which files each child agent reads and writes in one shared append-only log (owner-only, bounded) and tells a child, once per stale path, when a sibling changed a file it had read or written; the Tracked tool decorator records read_file / write_file / edit_file / delete_file on success. Interrupts gain a source: a notice is delivered at the next safe point as an attributed entry (source: notice) and never withdraws output or supersedes a final answer. Wiring into tole run children follows separately.
  • Sibling change notices (#380): sibling_watch tracks which files each child agent reads and writes in one shared append-only log (owner-only, bounded) and tells a child, once per stale path, when a sibling changed a file it had read or written; the Tracked tool decorator records read_file / write_file / edit_file / delete_file on success. Interrupts gain a source: a notice is delivered at the next safe point as an attributed entry (source: notice) and never withdraws output or supersedes a final answer. Children spawned by agent_start get TOLE_AGENT_ID and a shared TOLE_AGENT_TOUCH_LOG; in a child, tole run wraps its file tools and runs the watcher, so a sibling's change reaches the model at its next safe point.
  • tole doctor coverage ledger (#378): every run is recorded per provider + model (level reached, first blocker, fix command, timestamp) in an owner-only doctor-ledger.json (atomic write, a corrupt file is an error, never replaced); --summary prints READY n-of-m + the first blocker and its fix, --no-ledger skips recording.
  • Soft interrupts (#377): a bounded queue on the session's CancelToken that the turn loop drains at the safe point between a settled tool and the next provider call, committing each message as an attributed user-role entry (interrupt: true). An urgent interrupt (or any interrupt, for a final answer) withdraws an output that has not taken effect, so no tool call is left without its result, and records the drop durably. Host entry points: POST /sessions/{id}/interrupt (tole serve) and the tole_session_interrupt MCP tool (409/error when no turn is running).
  • tole doctor (#378): tiered provider diagnostics — offline (wiring), catalog (live /models, model must be served) and full (chat, streaming and a real tool-call loop) — each blocker carries its fix command, and keys / URL credentials are never printed. Exits non-zero when the requested tier is not reached; --tier full is the release-validation gate.
  • Per-user-turn token stats (#379): tole status lists input / output / cache-read / cache-write / reasoning tokens per turn and the status JSON (GET /sessions/{id}/status, tole_session_status) gains an additive usage_report.turns array. Derived from the durable usage ledger, so old sessions read the same way and nothing is stored twice; a value no step reported is n/a / null, never 0, and no elapsed time is invented.

Fixed

  • A child agent running tole chat or tole resume now receives sibling change notices (#380) like tole run does: both faces run their turns on a session cancel token with the child's watcher attached (#428).
  • tole resume, tole chat --resume and resumed missions now use the session's own model (the durable fact/model register set by ACP's model picker) instead of falling back to TOLE_MODEL; only the server faces honored it before (#428). The missing-provider-config error is one clean line on every face (the server faces printed a run of spaces inside it).
  • tole status and tole sessions no longer count the stop gate's own feedback message as a user turn (#418).
  • tole doctor: concurrent runs no longer overwrite each other's ledger entry (load/record/save now happen under an exclusive lock on doctor-ledger.json.lock); the catalog tier's GET /models gets its own 20 s timeout instead of the ACP picker's 3 s convenience timeout, so a slow but healthy gateway is not reported as a blocker; and the offline tier now requires a host in the base URL (https://?x or https://u:p@/v1 no longer pass).
  • Sibling change notices: a child's watcher starts at the end of the shared touch log instead of folding every earlier child's history on start-up.
  • The optional web_search tool is registered with if let instead of an is_some() check followed by unwrap().
  • tole serve --transport mcp is hardened to parity with the REST transport: the bearer token is compared in constant time and its scheme is case-insensitive; failed authentication is rate-limited per source IP (10 per minute, then 429, same policy as REST); request bodies over 1 MiB are refused with 413 (declared or streamed, never buffered whole); a transient accept() error is logged and no longer ends the server and every session; and the no-op timeout() around the auth check is gone. The token comparison, header matching and limiter now live in one shared auth module used by both transports.

Changed

  • Quiet startup (#435): the probe misses uteke binary not found, cora binary not found and no GitHub origin remote detected are no longer printed on every run; set TOLE_VERBOSE=1 to see them (tole doctor reports cora and uteke regardless). A configured MCP server that registers no tools is still reported.
  • Child-launch contract (#443): tole_core::child_env is the one definition of the environment agent_start gives a child (TOLE_AGENT_DEPTH, TOLE_AGENT_ID, TOLE_AGENT_TOUCH_LOG, TOLE_AGENT_ROLE, TOLE_AGENT_HANDOFF, the mailbox room and memory backend): the parent writes it with ChildLaunch, and the child reads it back with depth / sibling / role (sibling tracking, the handoff tool, the depth cap). No behaviour change.
  • Session registry (#441): session_host::Sessions owns the live session map — capacity and eviction, the admission rule (admit: replace an idle id, refuse a busy one, evict for a new id) and the per-turn busy claim (claim_turn). tole serve, tole acp and the MCP session tools use it instead of each manipulating the map; the map itself is private (tole-cli API change). No behaviour change.
  • Session turn runner, part 3 (#428): turn_runner::cli_turn_token gives every CLI face (run, resume, chat) the same cancel token plus child sibling watcher; resume and chat now run their turns with that token.
  • Session turn runner, part 2 (#428): the memory loop's pre-turn recall and session remember live in turn_runner and every face uses them. Server-face sessions now report a failed or successful remember on stderr instead of dropping the result silently.
  • Session turn runner, part 1 (#428): one turn_runner module builds the provider for a session turn (env config, the session's model, tool specs, pinned system prompt, live-token sinks) for run, resume, chat, missions and the server faces, replacing six copies.
  • Tool roster (#420, 3/3): the task-list tools are registered by one tool_roster::register_todo (hydrated from the transcript; todo_write absent in plan mode) instead of five copies in run, resume, chat, mission and the session host.
  • Tool roster (#420, 2/3): server sessions (tole serve, tole acp, the MCP session tools) build their tools through the same tool_roster as the CLI, replacing the third copied builder. They gain verify_package, the strict binary probe (executable files only), and sibling tracking plus the handoff tool when running as a child agent; probe misses are reported on stderr. MCP servers on server faces remain a separate follow-up.
  • Memory loop on uteke rooms (#422, 2/3): --memory uteke stores session summaries in the room repo-<dir> (uteke remember --room) and recalls with uteke room recall instead of the namespaces uteke 0.21 deprecates; while the room is empty, recall falls back to the legacy namespace of the same name, so memory from earlier versions is still found. Child-agent mailboxes are rooms too (agent-<id>); consuming one forgets its memories, deletes the room and cleans any legacy namespace. MemoryConfig.namespace is renamed room (tole-core API).
  • tole_core::transcript (#418): one read-side view of the transcript conventions the turn loop writes — which user messages open a turn (not stop-gate feedback, not interrupts), which usage rows are provider steps (not rows holding only tole_* keys) and the token total. The turn loop, tole status, tole sessions, usage reports and mission budgets all use it, and embedders can count turns and steps without copying the rules.
  • Tool roster (#420, 1/3): the CLI faces (run, resume, chat, mission) and the MCP server faces (tole mcp, MCP-over-HTTP) build their tools through one tool_roster module instead of two copied builders. Plan mode is applied in one place, and there is one binary probe (binary_available, executable files only) and one GitHub-origin probe. The MCP server faces now report a missing uteke / cora binary or GitHub origin on stderr like the CLI does.
  • Memory loop injection hygiene (#384): the recalled batch is hard-capped at 24 items / 64 KiB and deduplicated; a malformed recall payload (non-array, or a hit without content) now fails the whole batch visibly instead of silently injecting fewer items; tole serve/MCP sessions report recall failures on stderr like the CLI does.