Skip to content

Bound the size and duration of a chat request - #4

Merged
krlex merged 1 commit into
developfrom
fix/assistant-request-limits
Aug 19, 2026
Merged

Bound the size and duration of a chat request#4
krlex merged 1 commit into
developfrom
fix/assistant-request-limits

Conversation

@krlex

@krlex krlex commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Closes the application half of M3 from the 2026-08-19 Codex review. The chart
half — always setting a bearer token — is forail-helm#7.

chat_max_concurrency caps how many generations run at once and says nothing
about how large or how long any one of them is. Four callers could hold every
slot for the full Ollama timeout with a prompt the size of a book, and the
service would report healthy throughout.

  • Message capped at 4000 characters (413 over it); a blank one is rejected
    rather than sent to the model.
  • History trimmed to the 20 most recent turns and 16000 characters rather
    than rejected — dropping the oldest turns costs a little context, while a 413
    mid-conversation ends it. History matters more than the message: every turn is
    re-sent to the model and paid for again on the next request.
  • Page context truncated to 200 characters. It is a route, not a payload.
  • Deadline of 180s on one streamed response, independent of the model's own
    timeout. A generation that will not stop still ends, because the slot it holds
    is one of only four.

All four are settings, so an operator who wants longer conversations can have
them. Documented alongside FORAIL_ASSISTANT_CHAT_TOKEN, whose empty default
leaves the endpoint open — worth saying plainly, since that default is what made
the chart's omission a problem.

Verified

38 tests pass (31 before). The new ones cover each bound, including that an
endless generation is cut rather than drained — the generator does not run to
completion.

`chat_max_concurrency` caps how many generations run at once and says nothing
about how large or how long any one of them is. Four callers could hold every
slot for the full Ollama timeout with a prompt the size of a book, and the
service would look healthy the whole time.

- The message is capped at 4000 characters (413 over it) and a blank one is
  rejected outright rather than sent to the model.
- History is trimmed to the most recent 20 turns and 16000 characters rather
  than rejected: dropping the oldest turns costs a little context, while a 413
  in the middle of a conversation ends it. History matters more than the message
  here -- every turn is re-sent to the model and paid for again on the next
  request.
- The page context is truncated to 200 characters. It is a route, not a payload.
- A generation gets a 180s deadline independent of the model's own timeout. One
  that will not stop still ends, because the slot it holds is one of only four.

Defaults are settings, so an operator who wants a longer conversation can have
one. Documented alongside the chat token, whose empty default leaves the endpoint
open -- the chart now always sets it.
@krlex
krlex force-pushed the fix/assistant-request-limits branch from de0afc7 to 93c7671 Compare August 19, 2026 21:17
@krlex
krlex merged commit 50ad12a into develop Aug 19, 2026
2 checks passed
@krlex
krlex deleted the fix/assistant-request-limits branch August 19, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant