Tool-aware routing: what the decision costs
Last updated: 2026-11-25T02:23:00-03:00 (UTC-3)
How much time the trajectory strategy of automatic routing adds to a request. The strategy reads the conversation the client sent, scores the newest tool results and moves the session’s state; it calls no model unless you configure a judge.
What to expect
Section titled “What to expect”- A typical agent turn costs about a tenth of a millisecond: around 50 messages, a few kilobytes.
- A very long conversation costs one to two milliseconds: 600 messages, 80 to 95 KiB. Almost all of it is reading the JSON of the conversation once; the scoring itself looks only at the last few tool results.
- No provider call is added. The figures below made none.
- The cost is the same order on the three APIs. Messages is slightly slower because each message’s content blocks are read to find tool results.
The gateway also reports this for your own traffic, per strategy, in gateway_auto_route_decision_duration_seconds.
Method
Section titled “Method”A probe in the gateway’s own test suite (internal/gateway/trajectory_probe_test.go, run only on request) builds a coding run of reads, failing and passing test runs and edits, renders it as a Chat Completions, a Messages and a Responses conversation, and times the whole decision in process, through the function the request path calls: reading the conversation of that API, scoring it, loading and saving the session’s state. The request’s own JSON decoding, which every request pays with or without routing, is outside.
- One Apple M4 Pro machine with other work running on it, so the p95 and the slowest run include scheduling noise; the p50 is the steadier figure.
- A session identifier is present and every decision is a new turn, so the session table is read and written each time.
The recorded run is in trajectory-routing.json.
| API | Messages or items | Conversation size | p50 (ms) | p95 (ms) | Slowest (ms) |
|---|---|---|---|---|---|
| Chat Completions | 49 | 7 KiB | 0.10 | 0.11 | 0.9 |
| Messages | 49 | 7 KiB | 0.12 | 0.17 | 1.1 |
| Responses | 49 | 6 KiB | 0.09 | 0.11 | 0.4 |
| Chat Completions | 599 | 86 KiB | 1.07 | 1.47 | 2.9 |
| Messages | 599 | 93 KiB | 1.35 | 1.81 | 6.2 |
| Responses | 599 | 77 KiB | 0.96 | 1.44 | 1.9 |
Each row is 2,000 decisions after 200 warm-up ones, recorded 2026-11-25. Provider calls made by the decisions: 0.
Reading it
Section titled “Reading it”A request to a provider takes hundreds of milliseconds to seconds, so the decision is not what an agent waits for. What matters with this strategy is the other cost it can cause: a switch of model leaves the provider’s prompt cache behind. That is measured per transition (kept, switched, back) by the metrics and the report described in automatic routing, not here.