Skip to content

acp-tools: Add a probe that lists an ACP adapter's commands - #9

Merged
cgwalters-bot merged 1 commit into
cgwalters-forge:mainfrom
cgwalters-bot:dispatch/implement/agent-run-41165565378
Nov 4, 2026
Merged

cgwalters-bot merged 1 commit into
cgwalters-forge:mainfrom
cgwalters-bot:dispatch/implement/agent-run-41165565378

Conversation

@cgwalters-bot

Copy link
Copy Markdown
Collaborator

Add an acp-tools subcommand that starts an ACP adapter over stdio, sends initialize and session/new, waits for available_commands_update, and prints the adapter's agentCapabilities and the names of the commands it offers. This ports the one-off probe from cgwalters-forge/tracker#677 into the toolbox. Output is plain text by default and one JSON object with --json. The whole exchange has one deadline, --timeout (default 30s, max 600s), so a stuck adapter cannot hang the caller. Timeouts, adapter exit and JSON-RPC errors exit 1 with a message saying which step failed. The tool reads no credentials and opens no network connections; the adapter inherits the environment. It adds a serde_json dependency.

Verified with cargo fmt and just check; the tests use an inline sh fake adapter, with no real model. The repository has no just fmt recipe, so I ran cargo fmt directly.

Two review passes ran, with no blockers. The first pass found that the wait could outlast the deadline when an adapter closed stdout but kept running; that is fixed. Follow-ups still open: a failed write waits out the rest of the deadline before reporting (a short grace period would avoid that); writes to an adapter that never reads stdin are not bounded by the deadline; an error reply with "id": null reports as a timeout rather than the error; adapter output in error messages has no length cap; and no tests yet cover a session/new error or an update that arrives before the session/new response.

Closes #4

Generated by dispatch · ◷

Port the one-off probe from cgwalters-forge/tracker#677 into the toolbox,
so checking which commands an ACP adapter offers no longer needs an ad hoc
script. It speaks just enough ACP to get the adapter's agentCapabilities
and its available_commands_update.

The whole exchange has one deadline, and adapter output is bounded in
line size and queue depth, so a stuck or noisy adapter cannot hang the
caller or exhaust its memory.

Verified with `just check`, using inline `sh` fake adapters.

Generated-by: https://github.com/cgwalters/#llms

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: CHANGES

Reviewed admitted head a34942e8894e4403d0748010d878236382e055c5 against merge base 5e5eae2a9fb8646c2cefeaf6745aab2af0f39b5a.

  1. blocker — The advertised whole-exchange timeout does not bound the exchange. crates/misctool/src/acp_tools.rs:140-142 performs synchronous writes with no deadline. An adapter can read initialize, emit a request with a string ID larger than the pipe capacity, then stop reading stdin; the mirrored ID in the error reply blocks this thread indefinitely, so even --timeout 1 never reaches cleanup. Independently, at crates/misctool/src/acp_tools.rs:158-161, expiration merely changes recv_timeout to a zero-duration receive: queued messages still succeed. A continuous stream of ignored notifications or blank lines can therefore keep the loop alive past its deadline. Bound writes as well as reads, and explicitly reject an expired deadline before consuming another message. Add regressions for a non-reading adapter and continuously available irrelevant output, with an independent outer watchdog so the tests cannot hang.

  2. important — Adapter output is buffered without any memory bound. crates/misctool/src/acp_tools.rs:107-111 combines an unbounded channel with BufRead::lines(), which also accumulates an unlimited unterminated line. A noisy adapter can exhaust the probe's memory through either a single enormous line or a backlog of small messages; the timeout is not a memory limit. Set a maximum frame size and bound the pending-message queue, while preserving deadline enforcement when applying backpressure. Cover both oversized unterminated output and a producer faster than the consumer.

  3. important — An early command update bypasses the session creation result. crates/misctool/src/acp_tools.rs:281-285 returns success on available_commands_update even while session_created is false. If the adapter sends the update before its session/new response, the probe kills it and reports exit 0 without ever checking that response; a subsequent JSON-RPC error or missing response is silently treated as success despite the documented error behavior. Retain the early update, wait for a successful session response, and only then return the command list. Add tests for update-before-success, update-before-error, and update-without-response.

No workflow or ownership-policy files change in this diff. A person still needs to approve the merge.

Generated-by: https://github.com/cgwalters/#llms

Generated by review for #9 at a34942e

@cgwalters-bot

cgwalters-bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

✅ dispatch ended well. Result: #9

@cgwalters-bot
cgwalters-bot force-pushed the dispatch/implement/agent-run-41165565378 branch from a34942e to 6d70b88 Compare November 4, 2026 21:03

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: APPROVE

Reviewed admitted head 6d70b8838a32c374d2da83689a325364245306c8. No blockers found. A person still needs to approve the merge.

Follow-ups

  • important — crates/misctool/src/acp_tools.rs:275–280: terminate the adapter's descendants, not just its immediate wrapper. Drop kills only the direct child, while adapter descendants inherit the caller's stderr through Stdio::inherit(). For example, acp-tools --timeout 1 -- sh -c 'sleep 300; :' kills the shell at the deadline but leaves sleep running with stderr open. A caller using Command::output() or another output-capturing subprocess API consequently waits for that descendant to close the pipe, potentially indefinitely, even though the CLI process itself exits on time. Wrapper-based adapter launchers can exhibit this without malicious behavior, and successful probes can leave workers running too. Establish and clean up an adapter process group/tree, and add a regression case with a non-exec wrapper that checks both bounded output collection and descendant cleanup; the existing timeout cases use exec and miss this.

Generated by review for #9 at 6d70b88

@cgwalters-bot
cgwalters-bot merged commit d0291f1 into cgwalters-forge:main Nov 4, 2026
13 checks passed
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.

Seed subcommand: list an ACP adapter's offered tools

1 participant