Skip to content

feat(zeph-core): intra-turn parallel tool dispatch via dependency DAG (LLMCompiler)#1712

Merged
bug-ops merged 1 commit intomainfrom
parallel-tool-dispatch
Mar 13, 2026
Merged

feat(zeph-core): intra-turn parallel tool dispatch via dependency DAG (LLMCompiler)#1712
bug-ops merged 1 commit intomainfrom
parallel-tool-dispatch

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 13, 2026

Summary

Implements LLMCompiler-style parallel tool execution within a single agent turn (issue #1646).

  • ToolCallDag (tool_call_dag.rs): builds a dependency graph from tool_use_id references in tool arguments using Kahn's algorithm, partitions calls into topological tiers. Exact whole-value matching prevents false positives with short Ollama integer IDs.
  • Tiered dispatch in handle_native_tool_calls: calls in each tier execute concurrently via join_all; dependent calls wait for the previous tier; failed/ConfirmationRequired calls propagate a synthetic error to their dependents.
  • Cycle detection: falls back to full sequential execution (original order) with a warn! log entry.
  • TUI status: emits "Executing tool tier N/M…" messages for multi-tier batches.
  • Cancel support: cancel token is checked at all tier boundaries.

Test plan

  • 11 unit tests in tool_call_dag.rs covering: trivial fast path, linear chain, diamond DAG, cycle fallback, Ollama short-ID no-false-positive, nested JSON traversal, self-reference, ConfirmationRequired propagation
  • cargo nextest run --workspace --features full: 5359 passed (+327 vs main)
  • cargo clippy --workspace --features full -- -D warnings: clean
  • cargo +nightly fmt --check: clean

Follow-up issues (deferred from this PR)

  • Integration test for ConfirmationRequired dependency propagation (TC-MISSING-01, medium)
  • Cache extracted string values in ToolCallDag to avoid double scan (PERF-02, low)
  • Add depth guard to collect_strings recursion (PERF-03, low)
  • Suppress ToolStartEvent for pre-failed dependent tools (M3, cosmetic)

Closes #1646

@github-actions github-actions bot added enhancement New feature or request size/XL Extra large PR (500+ lines) documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate and removed enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 13, 2026
… (LLMCompiler)

Implements LLMCompiler-style parallel tool execution within a single agent turn.
Independent tool calls now execute concurrently; calls that reference another
call's tool_use_id as an argument value execute in topological tiers.

- Add `crates/zeph-core/src/agent/tool_execution/tool_call_dag.rs`: `ToolCallDag`
  builds a dependency graph via Kahn's algorithm, partitions calls into tiers,
  detects cycles (falls back to full sequential execution with a warning)
- Modify `handle_native_tool_calls` in `native.rs`: tier-based dispatch with
  per-tier `join_all`, cancel token propagation, `ToolStartEvent` per tier,
  TUI status messages for multi-tier batches, synthetic errors for dependents
  of failed/ConfirmationRequired prerequisite calls
- Dependency detection uses exact whole-value matching (not substring) to avoid
  false positives with short Ollama-style integer IDs

Closes #1646
@bug-ops bug-ops force-pushed the parallel-tool-dispatch branch from 097826a to b07e566 Compare March 13, 2026 23:30
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 23:30
@github-actions github-actions bot added enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 13, 2026
@bug-ops bug-ops merged commit da24f2d into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the parallel-tool-dispatch branch March 13, 2026 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

research(tools): parallel tool dispatch within a single LLM response (LLMCompiler)

1 participant