Skip to content

[#331] Batch read-only tool calls in a turn - #334

Draft
Youssef-joe wants to merge 2 commits into
mnemosyne-systems:mainfrom
Youssef-joe:subagents-turn-batching
Draft

Youssef-joe wants to merge 2 commits into
mnemosyne-systems:mainfrom
Youssef-joe:subagents-turn-batching

Conversation

@Youssef-joe

@Youssef-joe Youssef-joe commented Nov 8, 2026 •

Copy link
Copy Markdown

Why

A turn that asks for several files is common, but today only subagent starts overlap: every other call runs one after another. This makes read-heavy turns needlessly slow. Follow-on to #331.

What changed

  • ToolExecutor::parallel_safe() — a conservative, name-level allowlist of read-only tools: show_file, list_directory, search_text, expand_context, fetch_url, web_search, use_skill.
  • ToolExecutor::lists_agents() — run_agent with agent: "list" is a local registry search, not a subagent start, so it counts as read-only. starts_subagent() keeps real starts in the subagent batch.
  • ToolExecutor::has_agent_hooks() — read batching is disabled when hooks are installed, because hooks can observe call order.
  • BatchKind + parallel_run() in src/session.rs replace the inline runs_subagent scan.
  • Batches are homogeneous: subagent starts with subagent starts, read-only calls with read-only calls, never across the two.
  • Two continue_agent calls for the same task never share a batch; different tasks may.
  • doc/manual/en/30-tools.md concurrency wording updated.

Safety

Deliberately excluded: file writers, run_shell_command (can do anything), browse (stateful page-link numbers), graph_* / semantic_search (may build or refresh caches), and MCP tools (approval policy, unknown side effects). Results are still written back in the order the model asked for them.

Tests

Four new unit tests in src/session.rs:

  • read_only_calls_overlap_but_writes_do_not
  • a_read_and_a_subagent_do_not_overlap
  • continuations_of_one_task_stay_in_order
  • listing_agents_is_read_only_but_starting_one_is_not

Verification:

cargo test --lib                                   # 856 passed, 0 failed
cargo fmt --all -- --check                         # clean
cargo clippy --lib --tests -- -D warnings          # clean

Notes

  • No new tool, schema, config key, or prompt tokens; this changes execution only.
  • Adds me to AUTHORS as required for a first contribution.

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.

1 participant