Kommander supports many conversations running at the same time, but tool calls within one conversation are currently executed sequentially. This keeps the message history deterministic and ensures each tool result is appended before the next model round starts.

Current Behavior

ScopeBehavior
Across conversationsTool-call streams can run concurrently. The load test starts 100 conversations at once.
Within one conversation roundTool calls emitted in the same model response are executed one after another.
Across tool roundsThe final model response waits until all tool results from the current round are appended.
Audit writesTool audit writes are awaited on the tool-call path.
Customer-data checksBudget, rate-limit, identity, and circuit-breaker checks are performed before connector execution.
Connector failuresRepeated failures can open the connector circuit breaker; blocked calls do not reach the connector executor.

The default maximum tool-call loop is three rounds unless KOMMANDER_MAX_TOOL_ROUNDS is set to another positive integer.

Timing and Feedback

Each registry execution is wrapped by a tool timeout. The current registry timeout is 10 seconds. Long-running tools can emit progress feedback every 2 seconds through the tool-call handler when the caller provides a progress callback.

Customer-data connectors also have their own request limits and circuit-breaker behavior. A connector may fail with timeout, error, or circuit_open depending on whether the registry timeout, outbound request limit, or circuit breaker is the limiting control.

Load-Test Coverage

The load-test plan is maintained in docs/concurrent-tool-call-load-tests.md. Run it with:

yarn test:load:tools

The suite uses node:test, tsx --test, synthetic OpenAI streams, mocked connector execution, and an in-memory audit-log database stub. It does not require network access or real connector credentials.

Acceptance Thresholds

ThresholdExpected value
Concurrent conversations100 complete.
Total tool calls300 execute and audit-log.
P95 tool execution latencyBelow 2 seconds.
P95 added orchestration overheadBelow 2 seconds.
Peak heap growthBelow 64 MiB.
Circuit breakerCircuit-open results are observed after repeated connector failures.
Circuit isolationOnce open, blocked calls do not reach the connector executor.

CPU usage is sampled with process.cpuUsage() for every run.

Known Bottlenecks

The current bottlenecks are intentional documentation of the existing implementation, not target architecture:

  • Tool calls inside one conversation are sequential in streamWithToolCalls.
  • Audit writes are awaited and can add user-visible latency if MongoDB is slow.
  • The final LLM round cannot start until every tool result has been appended.
  • Customer-data rate-limit and budget checks are awaited for each tool call.

If realistic connector delays cause the load test to fail, inspect those areas before relaxing latency targets.