feat(runtime): set context window by hardware profile - #26
Closed
kristoffersodersten wants to merge 1 commit into
Closed
feat(runtime): set context window by hardware profile#26kristoffersodersten wants to merge 1 commit into
kristoffersodersten wants to merge 1 commit into
Conversation
Propagate explicit num_ctx values through profiles, bootstrap, LaunchAgent state, health truth, and every Ollama generation request. Reject invalid overrides and preserve embedding behavior.
There was a problem hiding this comment.
Pull request overview
Updates the runtime profile system to set and propagate an explicit Ollama context window (num_ctx) based on the selected hardware profile, carrying it through bootstrap/install flows, LaunchAgent environment, runtime configuration, health reporting, and all generation requests.
Changes:
- Add
num_ctxto runtime profiles (Fast=16,384; Balanced/Advanced=32,768) and expose it via bootstrap commands. - Extend
OllamaConfig/OllamaClientto parse/validateCHROMEAI_OLLAMA_NUM_CTX, surface it inhealth(), and include it in every/api/generaterequest’s options. - Wire
CHROMEAI_OLLAMA_NUM_CTXthrough macOS bootstrap/install scripts, LaunchAgent plist templating, README guidance, and server tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/server/test_runtime_profiles.py | Adds assertions and new tests validating profile num_ctx, env overrides, validation behavior, and per-request propagation. |
| server/runtime_profiles.py | Adds num_ctx to profile definitions and includes it in bootstrap command metadata. |
| server/ollama_client.py | Introduces num_ctx configuration + validation and ensures all generation payloads include options.num_ctx while keeping embedding requests unchanged. |
| scripts/install-macos-local.sh | Templates CHROMEAI_OLLAMA_NUM_CTX into the LaunchAgent plist and prints it in post-install guidance. |
| scripts/bootstrap-macos-local.sh | Emits/exports num_ctx from the selected profile and passes it into the installer environment. |
| README.md | Documents profile-driven context window defaults and the override environment variable. |
| launchd/com.chromeai.nano.plist | Adds the CHROMEAI_OLLAMA_NUM_CTX environment key to the LaunchAgent template. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+78
to
79
| for key in ("selected_profile", "generation_model", "embedding_model", "num_ctx", "reason"): | ||
| print(f"{key.upper()}={shlex.quote(str(payload[key]))}") |
| "command": command, | ||
| "generation_model": profile.generation_model, | ||
| "embedding_model": profile.embedding_model, | ||
| "num_ctx": profile.num_ctx, |
Owner
Author
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
num_ctx=16384for Fastnum_ctx=32768for Balanced and manual AdvancedStack boundary
This PR targets
codex/sod-395-hardware-aware-gemma4. Its diff contains only seven SOD-396 files. It does not modify PR #22 or claim delivery tomain.Verification
Exact SHA:
b490bd08f7a1847953159a31bccc475556a13afbHetzner:
ollama.num_ctx == 16384on the default Linux/unknown-memory profileLocal bounded:
Remaining target-hardware evidence
A real long-input M4/M1 run remains required before SOD-396 is marked Done. No model was downloaded and no consent boundary was crossed.