Skip to content

feat(tools): run_command + uteke first-class + startup probing (B4/B5) - #45

Merged
ajianaz merged 2 commits into
developfrom
feat/b4-dynamic-tools
Aug 27, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/b4-dynamic-tools

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What

run_command (B4 — owner-approved design, TOML DSL rejected for UX): generic dynamic tool. The command line is split to argv with a shlex-compatible subset (single/double quotes, backslash escapes) — no shell, so pipes/&&/redirects are literal argv characters. Runs cwd-jailed to the session dir with the hard subprocess timeout. Risk ceiling structurally Write. The approval prompt shows the exact argv — what you approve is what runs.

Uteke first-class (B4/B5): UtekeRecallTool — the B5 rename of uteke_search (name now matches the verb) plus a real fix: the old spec advertised a room parameter that execute silently ignored; recall is now genuinely room-scoped via uteke room recall <room> <query> --json. UtekeDocumentTool — the owner's markdown-to-room workflow: doc create with content piped via stdin (no argv length limits, no document content visible in ps), then room add-document; slug and room are validated against leading-hyphen argv-flag injection (--json as a slug passes a charset check but would be parsed as a flag).

Startup probing (B4): binary_available() gates CLI-backed tools — a missing uteke binary degrades to an explicit warning at startup, never phantom tools that fail on every call.

Why

B4/B5 close Track B of the v1.1 roadmap: dynamic tools without a DSL (generic + approval-gated beats config-as-code for this product), uteke as the only first-class memory integration, and honest startup behavior when engines are absent.

Testing

  • 135/135 tests (+9 run_command incl. cwd-jail + status passthrough + unterminated quotes; +11 uteke incl. flag-injection rejects), clippy clean.
  • Live validation (real provider): (1) run_command — approval prompt showed run: uname -s, approved, executed, answered Linux; (2) uteke_recall called room-scoped ({"query":"tole","room":"tole-dev"}) — visible in the durable log; (3) this host's uteke binary is binfmt-broken, and the error was surfaced to the model as a tool error while the session survived — graceful degradation by design. The uteke CLI contract (doc create --file -, room add-document) was verified directly from the uteke source (cli.rs + docs/cli-reference.md).

run_command (B4): generic dynamic tool, owner-approved design. Input
command line is split to argv with a shlex-compatible subset (single/
double quotes, backslash escapes) — NO shell, so pipes/&&/redirects are
literal characters. Runs cwd-jailed to the session dir with the hard
subprocess timeout. Risk ceiling is structurally Write. The approval
prompt shows the exact argv: what you approve is what runs. 9 tests
incl. jail cwd + exit-code passthrough + unterminated-quote errors.

uteke first-class (B4): UtekeRecallTool (B5 rename of uteke_search —
the name now matches the verb; gains real room-scoped recall via
'uteke room recall <room> <query>', which the old spec advertised but
never wired) + UtekeDocumentTool (owner's markdown-to-room workflow:
doc create via stdin — no argv length limits, no content in ps output
— then room add-document; slug/room validated against leading-hyphen
argv-flag injection). 11 tests.

Startup probing (B4): binary_available() gates CLI-backed tools; a
missing uteke binary degrades to an explicit warning — no phantom
tools that fail on every call.

Live validation: run_command approved and executed (uname -s → Linux)
via the interactive gate; uteke_recall called room-scoped from the
durable log; the host's broken uteke binary surfaced its error to the
model gracefully and the conversation survived.
}))
}

fn execute(&self, input: Value) -> Result<Value, String> {
if !out.status.success() {
let stderr = String::from_utf8_lossy(&out.stderr);
let snippet: String = stderr.chars().take(500).collect();
return Err(format!(
}

// 2) Link to the room when one is resolved.
let mut linked = false;
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

1. Pipe deadlock (uteke.rs): doc-create wrote markdown to the child's
   stdin while stdout/stderr sat unread — classic pipe-buffer deadlock
   for large documents or chatty CLIs. New shared helper
   run_with_timeout_stdin: writer thread for stdin, drain threads for
   stdout/stderr, hard timeout. Regression test feeds stdin AND reads
   200KB of output simultaneously.

2. Missing timeout (uteke.rs): doc-create bypassed run_with_timeout —
   a hung uteke would freeze the agent loop forever. Now on the same
   SUBPROCESS_TIMEOUT ceiling as every other invocation.

3. Inconsistent room validation (uteke.rs): UtekeRecallTool passed
   input[room] straight into argv — a model-supplied '--json' would be
   parsed as a CLI flag. Recall now applies the same leading-hyphen +
   charset defense as the document tool. 2 regression tests.
@ajianaz
ajianaz merged commit 7b1f74c into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/b4-dynamic-tools branch August 27, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants