Repository navigation
fix(vlm): send Ollama num_ctx as a top-level option - #5033
Merged
Merged
Conversation
LiteLLM forwards extra_body verbatim as top-level JSON for the ollama/ routes, and Ollama only reads num_ctx from options. Putting the default (or a user's extra_request_body value) inside extra_body therefore reached the server as an unknown top-level field, so the model kept its 4096-token default and long extraction prompts were truncated to ~2050 tokens. Pass num_ctx as a top-level argument, which LiteLLM maps into options.num_ctx, and drop it from extra_body. think is accepted top-level by Ollama either way, so it stays in extra_body.
qin-ctx
approved these changes
Sep 17, 2026
3 of 4 tasks
frankyang2008-eng
added a commit
to frankyang2008-eng/OpenViking
that referenced
this pull request
Oct 9, 2026
… isolation, plugin single-connection, VikingBot/Feishu studio, model network discovery) 22 upstream commits (PR volcengine#5096-volcengine#5139), 325 files, +13843/-3289. Themes - queuefs: isolate the background queue from the HTTP event loop (volcengine#5096) - plugins: resolve one connection per plugin hooks + MCP proxy (volcengine#5132); run shell commands that carry viking URIs (volcengine#5131) - studio: VikingBot conversations and Feishu onboarding (volcengine#5109); themes, dashboard and localized task pipeline (volcengine#5138, volcengine#5129, volcengine#5116, volcengine#5118) - models: network service discovery hooks, new openviking/models/network.py (volcengine#5117); Ollama num_ctx as a top-level option (volcengine#5033) - ingest: MiMo / MiMoCode log source, new openviking/ingest/sources/mimo.py - server: fewer request cycles and lower GC latency (volcengine#5127) Conflicts (7) and resolutions - queuefs/{add,external_task,session_commit}_processor.py - upstream volcengine#5096 removed OwnerLoopDispatcher and the service_loop constructor arg. The fork's only local change to these files was relocating task_work_index from openviking/service/ to openviking/storage/queuefs/. Took upstream's refactor, kept the fork's module path, dropped the now-unused import. Verified consistent: every construction site (service/core.py and all 5 test files) already uses the new signature; no get_running_loop is passed to any processor anywhere in the merged tree. - examples/claude-code-memory-plugin/scripts/config.mjs - union of both improvements: upstream's injectable { env = process.env } = {} param plus the fork's HARNESS constant in place of the hardcoded "claude-code" literal. - examples/memory-plugin-shared/credentials.test.mjs - upstream rewrote credentials.mjs; resolveOpenVikingCredentials no longer exists. Took upstream's imports, added back detectHarness/buildUserAgent for the fork's appended harness-detection tests (21 fork tests counted). - web-studio/src/routes/tasks/route.tsx (7 hunks) - fork changes were Prettier reflows plus bilingual inline ternaries, both superseded by upstream volcengine#5116 (t() i18n) and volcengine#5118 (skippedReason refactor). Took upstream's side. Verified: the merged onSuccess consumes result.skippedReason and localizeSkippedCommit is imported, so taking the fork's side would have orphaned that return and silently dropped the skip notice. - examples/codex-memory-plugin/README.md - took upstream's hook table (adds the PreToolUse (Bash) row). Not touched - bot/ carries 1787 pre-existing mypy errors across 258 files and is in no type gate. Two upstream volcengine#5109 files surfaced findings; left byte-identical to main to avoid diverging the fork and re-conflicting every sync. See plans/upstream-type-debt-20260917.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Send Ollama's
num_ctxas a top-level LiteLLM argument instead of insideextra_body.Why
For the
ollama/andollama_chat/routes, LiteLLM forwardsextra_bodyverbatim as top-level request JSON, and Ollama only readsnum_ctxfromoptions. So the default (and any user value fromvlm.extra_request_body) arrived as an unknown top-level field and was ignored — the model kept its 4096-token default and long prompts were truncated.Verified against LiteLLM 1.91.1 by capturing the outbound body with a local HTTP server, rather than reading the transformation in isolation:
extra_body={"num_ctx": 16384, "think": False}(before){"options": {}, "num_ctx": 16384, "think": False}— ignorednum_ctxtop-level,thinkinextra_body(after){"options": {"num_ctx": 16384}, "think": False}thinkis a valid top-level Ollama field, so it is left where it is; onlynum_ctxmoves.Tests
num_ctxassertions to check the top-level keyOllamaChatConfig.transform_requestand assertsoptions["num_ctx"], since asserting the built kwargs alone only proves where OV put the value, not the field Ollama readsassert kwargs["num_ctx"] == 16384, and theoptionsone); with it, all passtests/unit/test_extra_headers_vlm.py: 39 passed;ruff check/ruff format --checkcleanRelated: #4879, #4898. Closes #5030.