#5193·odysseus

Static context-window table overrides the endpoint's actual serving context — silent truncation in long agent sessions

Author: RodolifeCreated Jul 4, 2026Updated Sep 14, 2026
Labelsbugready for review

Prerequisites

  • I searched open issues and discussions and did not find an existing report of this bug.
  • This is not a security vulnerability. (Vulnerabilities go to GitHub Security Advisories — see SECURITY.md.)
  • I am running the latest code from the dev branch (the default branch you get on clone, where fixes land first) and the bug still reproduces there. Please git pull the latest dev before filing.

Install Method

Windows native (launch-windows.ps1)

Operating System

Windows

Steps to Reproduce

  1. Serve a Qwen3-family model in Ollama with a context smaller than the model's theoretical max (e.g. OLLAMA_CONTEXT_LENGTH=65536, or leave Ollama's much smaller default)
  2. Add the endpoint manually in Odysseus (Settings → Add Models)
  3. Start an agent session and watch the startup/request logs for the model context lines
  4. Run a long agent session that accumulates history past the real serving context

Expected Behaviour

Odysseus trims conversation history against the context the endpoint is actually serving, so the system prompt and tool instructions always survive.

Actual Behaviour

src/model_context.py logs "Using known context window for : 131072" from a static lookup table and trims against that. Ollama actually serves at its configured context (65536 in my case; the Ollama default is far smaller for users who never changed it). Once history exceeds the real serving context, Ollama silently truncates from the top — the system prompt and tool instructions are dropped first. Symptom: in long agent sessions the model gradually "forgets" its instructions, stops calling tools, or stalls, with no error logged anywhere.

Aggravating factor: manually added endpoints are stored with endpoint_kind="api", which bypasses any local-endpoint probing logic entirely, so even logic that could ask the endpoint never runs.

Suggested direction: probe Ollama's /api/show for the model — trust an explicit num_ctx Modelfile parameter fully, and treat model_info maxima as downward-only corrections (a probe should never raise the budget). Since OLLAMA_CONTEXT_LENGTH is not discoverable through any Ollama API, also document/expose an explicit override; the existing agent_input_token_budget setting is honored by context_budget.py and works for this. A local patch along these lines resolves it in my testing.

Logs / Screenshots

2026-07-03 14:58:54,130 - src.model_context - INFO - Using known context window for hf.co/HauhauCS/Qwen3.6-35B-A3B-Uncensored-HauhauCS-Aggressive:Q6_K_P: 131072
2026-07-03 14:58:54,130 - src.model_context - INFO - Context length for hf.co/HauhauCS/Qwen3.6-35B-A3B-Uncensored-HauhauCS-Aggressive:Q6_K_P: 131072

ollama ps (same moment):
NAME                                                                    SIZE     PROCESSOR    CONTEXT
hf.co/HauhauCS/Qwen3.6-35B-A3B-Uncensored-HauhauCS-Aggressive:Q6_K_P    31 GB    100% GPU     65536

Model / Backend (if relevant)

Ollama + qwen3-vl:32b and Qwen3.6-35B-A3B (HF GGUF import, hf.co/HauhauCS)

Are you willing to submit a fix?

Partially — I can help but need guidance

Additional Information

No response