Repository navigation
Description
Problem
An AI-Chat turn is slow, and the daemon log cannot say where the time goes. One question ("How many tasks are assigned to Anoop?") on deepseek/deepseek-v4.1-flash via OpenRouter took about 25s for the turn, plus about 6s of routing probe on the first load of the model. The same model answers a one-sentence prompt directly in about 1.2s.
What was observed (daemon log, one turn, no 429s)
| Step | Wall time |
|---|---|
| Routing probe: Stage 1 plus probe request (first load of a model only) | ~6s |
| Stage 1 routing request (4 tools) | ~0.4s |
| Main request (10 tool schemas) to first tool call | ~8.3s |
| Follow-up after the tool result (4 messages) | ~3.2s |
search_nodes natural-language to filter translation call (1 message, no tools) |
~2.1s |
| Second round (6 messages) to completion | ~11s |
Each row is one sequential request; the turn's ~25s is their sum. About five requests per prompt, each waiting for the last.
A second capture, Mistral Large on the same pipeline for "Could you check the status of tasks assigned to Michael": 5 rounds and about 96s. First main request 27s; the one-message, no-tool call after each search_nodes took 4s, 21s and 23s in later rounds.
What is not known
The log has no per-request duration, prompt size, or token usage, so the slow requests cannot be split into prompt size, reasoning tokens, provider queueing, or generating tool-call arguments. A reasoning model can spend its whole budget on reasoning (observed directly: deepseek-v4-flash with a small max_tokens returned no content). Nothing has been measured on a local model.
Proposed work
This issue is the measurement. What to change in the context the model is given, and the test prompts to measure against, are in #3706.
- Log per-request duration, time to first token, prompt tokens and completion tokens (including reasoning tokens) for OpenAI-compatible requests, at info level, and the same for the local engine.
- Log, per request, the assembled context's size by section and the tool schemas' size by tool.
- Measure the AI-Chat context is neither targeted nor grounded: too much that does not bear on the message, too little on what it is about #3706 test prompts end to end on a reasoning remote model, a non-reasoning remote model and a local model, and attribute the time.
- From the measurements, list candidate improvements, for example: tool surface size per request, number of sequential rounds, the natural-language filter translation call, running the routing probe off the user's critical path, and caching a failed probe.
Acceptance Criteria
- Each OpenAI-compatible and local request logs duration, time to first token, and prompt/completion/reasoning token counts.
- A measured breakdown of the AI-Chat context is neither targeted nor grounded: too much that does not bear on the message, too little on what it is about #3706 test prompts on a reasoning remote, a non-reasoning remote and a local model is recorded on this issue.
- Improvements are filed as separate issues, each citing the measurement that motivates it.
Activity
[-]Profile AI-Chat turn latency on OpenAI-compatible endpoints[/-][+]Profile AI-Chat turns (latency, context size, accuracy) and find how best to improve them[/+][-]Profile AI-Chat turns (latency, context size, accuracy) and find how best to improve them[/-][+]Profile AI-Chat turn latency on OpenAI-compatible endpoints and the local engine[/+]Ground project lookups and refuse relationship names as field values;…
Ground project lookups, refuse relationship names as field values, lo…
malibio commentedon Oct 10, 2026
Measurements (PR #3716; logging merged in #3709)
Per-request logging is in (duration, first byte, prompt/completion/reasoning tokens, section sizes), and the grounding eval can now run on a remote provider, so the breakdown below is from the logs of the final runs: 8 scenarios × 3 reps, OpenRouter.
A lookup turn is three sequential requests on both models: the Stage-1 routing request (~1.1K prompt tokens, ~0.8s), the main request with the six lookup tools (~6.6K, ~1.9s) and the follow-up after the tool result (~6.9K, ~1.9s), about 5s end to end. A write turn is longer (the assign turn is ~9s). Of Haiku's completions, about 40% are reasoning tokens (none on most requests, ~100–200 on the others). Time to first byte is where the two differ most: ~0.3s against ~1s.
Not re-measured: the DeepSeek ~25s and Mistral Large ~96s captures in this issue. The Mistral Large capture guessed
custom:assigneeand repeated a call until the duplicate guard fired; #3716 and #3709 change what the tools answer in those situations, but that model was not re-run, so the effect on its five rounds is unknown.Criteria
Skip the Stage-1 request for a settled lookup; read ids through the p…
malibio commentedon Oct 10, 2026
Update on the final tree (PR #3716, af216c1)
Improvement folded into #3716
The Stage-1 routing request was the first of a lookup turn's sequential requests, and for a question about what the workspace holds its answer was overridden anyway. It is no longer made for those messages. Per lookup turn:
What the numbers say about the other candidates
search_nodes5.3K,run_query3.9K,search_semantic2.9K). Shrinking it means trimming tool descriptions or narrowing the lookup tool set, either of which needs a measured pass against the routing and agent evals; it is not a safe edit without one.Criteria
Address re-review: keep compound questions with Stage 1, make id repa…
Make the lookup and assign paths hold on remote models; run the groun…
Skip the Stage-1 request for a settled lookup; read ids through the p…
Address re-review: keep compound questions with Stage 1, make id repa…
Make the lookup and assign paths hold on remote models; run the groun…
Address review: keep run_query's filter hints that stand alone, pin e…
Trim the lookup request: drop skill text the tool schemas repeat, sho…
Address review: keep run_query's filter hints that stand alone, pin e…
Trim the lookup request: drop duplicated skill and schema text (#3717)
malibio commentedon Oct 11, 2026
Closing as complete. All three criteria are met: per-request logging landed with #3709; the breakdown on a reasoning remote, a non-reasoning remote and a local model is in the comments above and on #3706; and the improvements the measurements supported are made rather than filed: the Stage-1 routing request is skipped for lookup turns (#3716), and the remaining lever named above, the size of a lookup turn's first request, was trimmed in #3717 (prompt tokens 6.77K to 6.41K, no measurable change in time to first token). Not redone: the DeepSeek and Mistral Large captures in the description were not re-run after these changes.