reflect: Ollama's context-overflow 400 is not recognised as an overflow, and `REFLECT_MAX_CONTEXT_TOKENS` ignores `LLM_OLLAMA_NUM_CTX`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
Direzione di ricerca
Start by reading _is_context_overflow_error in engine/reflect/agent.py and trace where the reflect context-token budget is configured from HINDSIGHT_API_LLM_OLLAMA_NUM_CTX and HINDSIGHT_API_REFLECT_MAX_CONTEXT_TOKENS. Check the existing overflow and budget tests before changing behavior. Done means Ollama’s reported wording triggers final synthesis, and the default budget respects the configured context size when the override is unset.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
With the Ollama provider, a mental-model refresh whose reflect loop outgrows the model's context fails outright
instead of falling back to a final synthesis from the evidence already gathered, and the page is then paused. Two
things combine:
_is_context_overflow_error(engine/reflect/agent.py) looks for phrases such ascontext_length_exceeded,
maximum context lengthandprompt is too long. Ollama words the error as "the prompt is longer than the context
length currently available to the model", which matches none of them, so the branch that forces final synthesis on
an overflow is skipped and the 400 ends the refresh.HINDSIGHT_API_REFLECT_MAX_CONTEXT_TOKENSkeeps its default of 100,000 even when
HINDSIGHT_API_LLM_OLLAMA_NUM_CTXtells Hindsight the model has 32,768. The budget is the threshold at which the
loop forces synthesis, so with these settings the loop keeps adding evidence long after the prompt has outgrown the
context Hindsight itself asked Ollama for.
Environment
hindsight-api1.3.0 (throughhindsight-embed) on macOS; both points are unchanged in v1.3.1 and onmain.HINDSIGHT_API_LLM_PROVIDER=ollama,HINDSIGHT_API_LLM_OLLAMA_NUM_CTX=32768,
HINDSIGHT_API_REFLECT_MAX_COMPLETION_TOKENS=8192;HINDSIGHT_API_REFLECT_MAX_CONTEXT_TOKENSnot set.- Ollama 0.40.19 with
qwen3.8:27b(Q4_K_M); Ollama's server log showsn_ctx = 32768on every load.
Actual Behavior
In the API logs we keep (2026-11-04 to 2026-12-04), 9 refresh_mental_model tasks failed with this error, one on
2026-11-25, seven on 2026-11-29 and one on 2026-11-30:
Task execution failed: refresh_mental_model, error: UpstreamHTTPError: HTTP 400 from http://127.0.0.1:11434/api/chat: {"error":"the prompt is longer than the context length currently available to the model; shorten the prompt, adjust the context length in settings, or use a model with a longer context length"}
The same 400 was logged twice more by reflect.agent as "closing done call failed, using the standalone prompt";
that fallback re-sends a prompt sized from the same budget. Each failed refresh set last_refresh_failed_at, so those
pages were left paused (they show in paused_mental_models since #6375).
Expected Behavior
- Ollama's wording counts as a context overflow, so the refresh synthesizes from what it has, as it would on
OpenAI'scontext_length_exceeded. - With
REFLECT_MAX_CONTEXT_TOKENSunset andLLM_OLLAMA_NUM_CTXset, the default follows the context: for example
num_ctx - reflect_max_completion_tokens, less a margin, since the budget is ano200k_baseestimate of the
messages that leaves out the tool schemas sent with each request (and with no completion cap set, some fixed share
ofnum_ctx). Withoutnum_ctx, Ollama 0.40.19 reports a loaded model's context ascontext_lengthin
GET /api/ps; a startup warning when the reflect budget exceeds it would at least make the mismatch visible.
Workaround
Setting HINDSIGHT_API_REFLECT_MAX_CONTEXT_TOKENS=24576 (32,768 - 8,192) has held since 2026-12-04 14:56: to 2026-12-05 08:49, 41 mental-model refreshes started (38 of them on 12-05) and none failed on the context.
- Lingua principale
- Python
- Stelle
- 45.2k
- Fork
- 5.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vectorize-io/hindsight
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineApertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
vectorize-io/hindsight#7240 · 1 commento ·
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
vectorize-io/hindsight#7231 ·
-
Flaky system test: test_embedding_and_rerank_calls_are_in_request_history raises StopIterationApertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
vectorize-io/hindsight#7228 · 1 commento ·
Tutte le issue di vectorize-io/hindsight
Issue simili
-
Test: to_hijri() accepts datetime.datetime and uses only the date partForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertagood first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
polish
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresForse già presa @AshutoshSingh840 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
UKGovernmentBEIS/control-arena#992 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
mvalentsev/awesome-free-ai-coding#70 ·
I maintainer di solito rispondono entro 1 giorno