Skip to content

Insights: keep a run inside the model's context window - #53

Merged
eddietejeda merged 1 commit into
mainfrom
insights-context
Oct 17, 2026
Merged

eddietejeda merged 1 commit into
mainfrom
insights-context

Conversation

@eddietejeda

Copy link
Copy Markdown
Contributor

The takeaways run on hototel.com failed with a 400 from the model server:

This model's maximum context length is 32768 tokens. However, you requested 8000 output tokens and your prompt contains at least 24769 input tokens

Every query result stays in the agent's transcript until the run ends, and a dozen 200-row results plus the 8k output reservation overflowed the window.

  • Model server: --max-model-len 65536 (already redeployed; the model supports 262k and the KV cache for 64k is a few GB of the headroom beside the weights).
  • Endpoint client: max_tokens 8000 → 4096. It is reserved out of the window up front; the longest answer is the ~2k takeaways JSON.
  • Tools: max_rows 200 → 80.
  • Prompt: aggregate in SQL and return the 10–30 rows that answer the question, never raw session rows or SELECT *.

Verifying with a real takeaways run against the production org database; result in a comment.

A takeaways run on the production org failed with the model's 400: 24,769
prompt tokens plus the 8,000 reserved for output exceeded the 32,768 limit.
Every query result stays in the transcript for the rest of the run, and a
dozen 200-row results add up.

Three changes: the model server's window is 64k (the model supports 262k;
KV cache for 64k is a few GB of what is left beside the weights), the
endpoint's max_tokens is 4,096 (the longest answer is the ~2k takeaways
JSON; the reservation is taken off the window up front), tool results are
capped at 80 rows, and the prompt asks the model to aggregate to the 10-30
rows that answer a question rather than return raw rows.
@eddietejeda
eddietejeda requested a review from a team as a code owner October 17, 2026 14:13
@eddietejeda
eddietejeda requested review from rohan-hotdata and removed request for a team October 17, 2026 14:13
@eddietejeda
eddietejeda merged commit ff0cb2a into main Oct 17, 2026
2 checks passed
@eddietejeda
eddietejeda deleted the insights-context branch October 17, 2026 14:16
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