Production LLM turns are slow — recent [llm] chat ok log lines show turns taking 39s, 39s, 170s, 223s (all finishReason: stop, so not 502s, just slow). The driver is the reasoning model (qwen3.8-27b) producing a long chain-of-thought in the reasoning field; generation time scales with CoT length.
reasoning_effort is already at low (the floor that still keeps thinking enabled) and LLM_MAX_TOKENS is 4000 (the model finishes within budget, so lowering it risks re-introducing the 502 budget-exhaustion issue). The controllable levers are prompt size and CoT length.
Change
Cap recentEvents in the turn prompt from the last 10 to the last 5 events (buildUserPrompt, server/engine.ts) — shrinks the input and the material the model has to reason over.
Add a "keep your reasoning brief" HARD CONSTRAINT to the system prompt (buildSystemPrompt) — nudges the reasoning model toward a shorter CoT before emitting the JSON. Reasoning stays enabled (not disabled); only its length is limited.
Both are prompt-level only: the deterministic stub, the TurnResult contract, max_tokens, and reasoning_effort are unchanged.
Expected effect
Lower average/tail turn latency and reduced risk of the 4000-token output budget being exhausted before the JSON answer (the original 502 failure mode).
Note
Follow-up identified from production logs (no prior issue). Version bump v0.8.0 → v0.9.0.
## Problem
Production LLM turns are slow — recent `[llm] chat ok` log lines show turns taking **39s, 39s, 170s, 223s** (all `finishReason: stop`, so not 502s, just slow). The driver is the reasoning model (`qwen3.8-27b`) producing a long chain-of-thought in the `reasoning` field; generation time scales with CoT length.
`reasoning_effort` is already at `low` (the floor that still keeps thinking enabled) and `LLM_MAX_TOKENS` is 4000 (the model finishes within budget, so lowering it risks re-introducing the 502 budget-exhaustion issue). The controllable levers are prompt size and CoT length.
## Change
1. **Cap `recentEvents` in the turn prompt** from the last **10** to the last **5** events (`buildUserPrompt`, `server/engine.ts`) — shrinks the input and the material the model has to reason over.
2. **Add a "keep your reasoning brief" HARD CONSTRAINT** to the system prompt (`buildSystemPrompt`) — nudges the reasoning model toward a shorter CoT before emitting the JSON. Reasoning stays enabled (not disabled); only its length is limited.
Both are prompt-level only: the deterministic stub, the `TurnResult` contract, `max_tokens`, and `reasoning_effort` are unchanged.
## Expected effect
Lower average/tail turn latency and reduced risk of the 4000-token output budget being exhausted before the JSON answer (the original 502 failure mode).
## Note
Follow-up identified from production logs (no prior issue). Version bump v0.8.0 → v0.9.0.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
Production LLM turns are slow — recent
[llm] chat oklog lines show turns taking 39s, 39s, 170s, 223s (allfinishReason: stop, so not 502s, just slow). The driver is the reasoning model (qwen3.8-27b) producing a long chain-of-thought in thereasoningfield; generation time scales with CoT length.reasoning_effortis already atlow(the floor that still keeps thinking enabled) andLLM_MAX_TOKENSis 4000 (the model finishes within budget, so lowering it risks re-introducing the 502 budget-exhaustion issue). The controllable levers are prompt size and CoT length.Change
recentEventsin the turn prompt from the last 10 to the last 5 events (buildUserPrompt,server/engine.ts) — shrinks the input and the material the model has to reason over.buildSystemPrompt) — nudges the reasoning model toward a shorter CoT before emitting the JSON. Reasoning stays enabled (not disabled); only its length is limited.Both are prompt-level only: the deterministic stub, the
TurnResultcontract,max_tokens, andreasoning_effortare unchanged.Expected effect
Lower average/tail turn latency and reduced risk of the 4000-token output budget being exhausted before the JSON answer (the original 502 failure mode).
Note
Follow-up identified from production logs (no prior issue). Version bump v0.8.0 → v0.9.0.