Skip to content

feat(runtime): set context window by hardware profile - #26

Closed
kristoffersodersten wants to merge 1 commit into
codex/sod-395-hardware-aware-gemma4from
codex/sod-396-explicit-context-window
Closed

feat(runtime): set context window by hardware profile#26
kristoffersodersten wants to merge 1 commit into
codex/sod-395-hardware-aware-gemma4from
codex/sod-396-explicit-context-window

Conversation

@kristoffersodersten

Copy link
Copy Markdown
Owner

Summary

  • set num_ctx=16384 for Fast
  • set num_ctx=32768 for Balanced and manual Advanced
  • propagate context through bootstrap, LaunchAgent state, runtime configuration, health truth, and every Ollama generation request
  • preserve explicit positive overrides
  • reject invalid or non-positive values
  • leave embedding requests unchanged

Stack 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 to main.

Verification

Exact SHA: b490bd08f7a1847953159a31bccc475556a13afb

Hetzner:

  • frozen install
  • lint and manifest lint
  • typecheck
  • unit suite: 5 panel + 33 server tests
  • privacy suite
  • build
  • runtime health assertion: ollama.num_ctx == 16384 on the default Linux/unknown-memory profile
  • bridge-backed E2E: 6 passed, 1 unpacked-Chrome test skipped because no Chrome executable was declared
  • clean exact-SHA worktree

Local bounded:

  • 11 targeted runtime tests
  • bootstrap/install shell syntax
  • LaunchAgent plist validation
  • diff check
  • SSH commit signature verification

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.

Propagate explicit num_ctx values through profiles, bootstrap, LaunchAgent state, health truth, and every Ollama generation request. Reject invalid overrides and preserve embedding behavior.
Copilot AI lite review requested due to automatic review settings August 18, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ctx to runtime profiles (Fast=16,384; Balanced/Advanced=32,768) and expose it via bootstrap commands.
  • Extend OllamaConfig / OllamaClient to parse/validate CHROMEAI_OLLAMA_NUM_CTX, surface it in health(), and include it in every /api/generate request’s options.
  • Wire CHROMEAI_OLLAMA_NUM_CTX through 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,
@kristoffersodersten

Copy link
Copy Markdown
Owner Author

Superseded by protected main PR #22. SOD-396 implementation and regression coverage are integrated and reverified on exact head fe5f79d; target-hardware long-input proof remains open.

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.

2 participants