bruteSourceBruteMiddlewareToolCall

class ToolCall

Executes pending tool calls from the LLM response.

Existing features (ref: opencode tool.ts wrap / truncate.ts):

  1. Universal output truncation — after every tool.call(), pass the result string through Brute::Truncation.truncate() which enforces a 2000-line / 50 KB cap. This is a safety net so no single tool result can blow up the context window, regardless of whether the tool itself has internal limits.
  2. Overflow to disk — when truncating, the full output is saved to a temp file under the truncation directory. The path is included in the truncated result with a hint.
  3. Configurable limits — MAX_LINES / MAX_BYTES default to 2000 / 50 KB.
  4. Skip truncation when tool already truncated — if the tool result already contains the truncation marker (e.g. Shell or FSSearch truncated internally), don't double-truncate.

== Concurrency model (Async)

Tool calls are executed concurrently using the async gem's fiber-based scheduler. Each tool call is dispatched as an Async::Task inside an Async::Barrier, so all tools run in parallel and we wait for every task to complete before moving on.

Key design decisions: