Skip to content

feat(tool): add BashToolBuilder::configure for full BashBuilder access#2104

Open
chaliy wants to merge 2 commits into
mainfrom
claude/bashtool-adapter
Open

feat(tool): add BashToolBuilder::configure for full BashBuilder access#2104
chaliy wants to merge 2 commits into
mainfrom
claude/bashtool-adapter

Conversation

@chaliy

@chaliy chaliy commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Why

Architectural item #2: BashToolBuilder re-declared a handful of BashBuilder knobs (username, hostname, limits, cwd, env, builtins) but couldn't reach the rest of the BashBuilder surface — network allowlist, mounts, hooks, git/ssh config, python/typescript, session/memory limits, etc. So tool users had strictly less power than Bash users (the "inconsistent coverage" half of the duplication critique, and the more impactful one).

The full-dedup alternative (route every setter through closures, drop the fields) doesn't work: the convenience fields are also read by the help / system-prompt text (it displays the configured username/hostname/limits/env), so they can't become opaque closures.

What

  • Add BashToolBuilder::configure(|b: BashBuilder| ...) — a thin-adapter escape hatch that runs against the fresh BashBuilder create_bash builds per execution, after the convenience setters so it can extend or override them. Any BashBuilder capability is now reachable from a tool.
  • Steps are Arc<dyn Fn(BashBuilder) -> BashBuilder + Send + Sync> so BashTool stays Clone and rebuilds an isolated shell per call.
  • Simplify input_schema / output_schema to call the static schema functions directly instead of reconstructing a throwaway BashToolBuilder from the tool's fields.

The convenience setters/fields are unchanged (no breaking change; bindings/CLI unaffected).

Tests

  • New test_configure_applies_to_underlying_bash_builder: .configure() sets env + overrides $USER via .username() on the underlying builder, and runs after the convenience .env() — output confirms both apply and configure wins.
  • Full bash_tool suite green: 2491 lib unit tests + 948 integration tests. CLI builds; fmt + clippy clean.

BashToolBuilder re-declared a handful of BashBuilder knobs (username,
hostname, limits, cwd, env, builtins) but couldn't reach the rest — network
allowlist, mounts, hooks, git/ssh config, python/typescript, etc. — so tool
users had strictly less power than Bash users (the 'inconsistent coverage'
half of the duplication problem).

Add BashToolBuilder::configure(|b: BashBuilder| ...), a thin-adapter escape
hatch that runs against the fresh BashBuilder create_bash builds per
execution, after the convenience setters so it can extend or override them.
Steps are Arc<dyn Fn(BashBuilder) -> BashBuilder + Send + Sync> so the tool
stays Clone and rebuilds a shell per call. The convenience fields stay (they
also feed the help / system-prompt text). Also simplify input_schema /
output_schema to call the static schema functions instead of reconstructing
a throwaway builder.
Copilot AI review requested due to automatic review settings June 19, 2026 20:46
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 19, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 3f151d7 Commit Preview URL

Branch Preview URL
Jun 19 2026, 08:49 PM

Copilot AI 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.

Pull request overview

Adds an escape-hatch API to let BashToolBuilder apply arbitrary BashBuilder configuration on each execution, closing the feature gap between direct Bash::builder() usage and the tool wrapper.

Changes:

  • Introduces BashToolBuilder::configure(...) storing Arc<dyn Fn(BashBuilder) -> BashBuilder + Send + Sync> steps and applying them last during BashTool::create_bash().
  • Simplifies Tool::input_schema() / output_schema() for BashTool to return the static request/response schemas directly.
  • Adds a test asserting that .configure() runs after convenience setters and can override them.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/bashkit/src/tool.rs
Per review: help()/system_prompt() are generated from the convenience
setters' stored fields, so values set only inside a configure() closure run
but don't show up in the documentation text. Document the caveat and point
users at the convenience setters for anything that should be documented.
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