#1101·honcho

Tool calls in one assistant turn run serially, so a turn costs the sum of its reads

Author: tomas-sereikisCreated Aug 29, 2026Updated Sep 23, 2026
Labelsenhancementmaintainer-approved

Problem

execute_tool_loop awaits each tool call in an assistant turn one at a time:

https://github.com/plastic-labs/honcho/blob/main/src/llm/tool_loop.py#L586

The model routinely asks for several independent reads at once — a dialectic turn typically emits search_memory and search_messages together — so the turn costs the sum of their latencies when it only needs to cost the slowest.

Traced on a production minimal dialectic (9.1s end to end):

10:04:21.4  request in
10:04:24.8  [tool call]   search_memory      ← 3.4s  first LLM call
10:04:26.0  [tool result] search_memory      ← 1.2s  embeddings + pgvector
10:04:27.9  [tool result] search_messages    ← 1.9s  embeddings + pgvector
10:04:27.9  max iterations (1)
10:04:30.3  response                         ← 2.3s  final LLM call

The 1.2s and the 1.9s are independent reads that ran back to back. Of the 9.1s, ~5.7s is LLM time and ~3.1s is tool execution.

Measured impact

Across 42 production dialectic requests (103 iterations, 77 of them multi-tool, 3.34 tool calls per iteration on average), grouping calls by the turn that issued them:

saving
aggregate over 1254s measured 11.3%
median request 9.3%
mean request 13.7%
p90 29.7%
best case 51.0%

Only 4 of the 42 requests gain nothing.

Why it is safe for reads

Tool handlers own their sessions: each opens a short-lived one via tracked_db(), and only the mutating handlers take ctx.db_lock — _handle_create_observations_impl, _handle_update_peer_card, _handle_delete_observations. Concurrent reads do not contend on shared state.

The ordering constraint

Mutations cannot simply be parallelised alongside reads. ctx.db_lock makes the mutating handlers take turns but does not decide whose turn comes first, so two writes from one turn could apply in an order the model did not request. Any fix has to keep state-changing calls in request order while letting reads overlap.

Proposed shape

  • Run a turn's non-mutating calls concurrently; keep mutating calls serial in request order.
  • Identify mutations by name from a set declared next to the dispatch table, rather than a per-caller "these are all reads" boolean — DIALECTIC_TOOLS already carries a commented-out create_observations_deductive, so a boolean would go quietly wrong the day someone uncomments it.
  • Default to fully sequential so no existing caller changes behaviour without opting in.
  • Cap the fan-out. Production has produced 18 tool calls in a single iteration; firing all at once would mean that many simultaneous embedding + pgvector queries on one instance.

Also worth noting: moving the per-call telemetry ContextVars (set_current_tool_call_seq, set_last_tool_metadata) inside each task makes them bind to their own call. Today they are written and read across one shared context, which only stays correct because nothing overlaps.

Status

Implemented with tests in #1100, opened before I saw the issue-gate requirement. Happy to close that and reopen against this issue, or to change the approach if you would rather it looked different.