opencode (pointed at http://litellm.home, model qwen3.8-27b-local) uses
correct context-window and compaction behavior for the deployed
llama.cpp/Qwen3.8-27B backend — with those numbers derived from this
repo's existing config (LLAMA_CTX_SIZE, litellm's max_tokens) rather
than hand-duplicated and drifting in opencode.json. opencode's provider
config (limit.context/limit.output) has no documented runtime
auto-discovery (confirmed in docs/research/opencode-cli-setup.md §5) —
so "auto-discovery" here means deciding how much of that gap this repo
closes with its own tooling (a generator script, docs, or just accepted
manual upkeep) vs. leaving it manual.
Notes
Domain docs: none yet (CONTEXT.md/docs/adr/ don't exist in this repo
— proceed silently per docs/agents/domain.md).
Read first: docs/research/opencode-cli-setup.md (opencode config shape), docs/research/qwen3.8-27b-quant.md (KV-cache/VRAM math), and docs/research/opencode-auto-compact.md (compaction trigger formula, on
the unmerged research/opencode-auto-compact branch — merge or
cherry-pick before relying on it).
Live config: ~/.config/opencode/opencode.json on this dev machine
carries the real litellm provider block, model default, and compaction
settings — see Decisions so far below.
Current backend facts: docker-compose.yml's llama-server runs with --ctx-size ${LLAMA_CTX_SIZE:-131072} (merged via #30); litellm's max_tokens is 16384. opencode reaches the model only through litellm,
per issue #15.
Invoke /research for opencode-internals questions, /grilling + /domain-modeling for decisions.
Decisions so far
How does opencode's auto-compact actually work? —
single global compaction block, triggers at usedTokens >= limit.context - min(20000, limit.output),
silently disabled if limit.context is unset. Findings: docs/research/opencode-auto-compact.md
on branch research/opencode-auto-compact.
Point opencode at litellm.home with a virtual key —
done. Provider block added, set as opencode's default model, smoke-tested end to end. Surfaced a
live bug in the process: LITELLM_MASTER_KEY doesn't start with sk-, so litellm rejects it on
every API endpoint — blocks minting new virtual keys via the documented API flow until fixed.
Context bumped to 128K end to end: LLAMA_CTX_SIZE raised 65536 → 131072 on the server
directly, ctx-size-128k branch merged into main (PR #30) so the repo's checked-in default now
matches, and ~/.config/opencode/opencode.json's limit.context updated to match — all three
reconciled, re-smoke-tested.
Not yet specified
Whether litellm's request-priority/caching (router_settings) has any interaction with opencode's
own context bookkeeping.
Whether the LITELLM_MASTER_KEY sk-prefix bug (found while resolving #29) is worth its own fix —
not yet a ticket; small enough it may just get fixed inline whenever someone's next in litellm-config.yaml/.env.
Out of scope
Tool-calling reliability of Qwen3.8-27B against llama.cpp/opencode (broken llama.cpp Jinja/tool-
parser bugs, documented in docs/research/opencode-cli-setup.md §4-5 and docs/research/qwen3.8-27b-tool-calling.md) — orthogonal to context-size/compaction.
opencode's websearch tool for the local model: confirmed unavailable by opencode's own design
(hosted-provider-only, or a paid Exa/Parallel key) — not something this stack's config can turn
on. User chose to leave it off rather than build an MCP bridge to this repo's SearXNG endpoint or
bring in a paid third-party search API.
## Destination
opencode (pointed at http://litellm.home, model `qwen3.8-27b-local`) uses
correct context-window and compaction behavior for the deployed
llama.cpp/Qwen3.8-27B backend — with those numbers **derived from** this
repo's existing config (`LLAMA_CTX_SIZE`, litellm's `max_tokens`) rather
than hand-duplicated and drifting in `opencode.json`. opencode's provider
config (`limit.context`/`limit.output`) has no documented runtime
auto-discovery (confirmed in `docs/research/opencode-cli-setup.md` §5) —
so "auto-discovery" here means deciding how much of that gap this repo
closes with its own tooling (a generator script, docs, or just accepted
manual upkeep) vs. leaving it manual.
## Notes
- Domain docs: none yet (`CONTEXT.md`/`docs/adr/` don't exist in this repo
— proceed silently per `docs/agents/domain.md`).
- Read first: `docs/research/opencode-cli-setup.md` (opencode config shape),
`docs/research/qwen3.8-27b-quant.md` (KV-cache/VRAM math), and
`docs/research/opencode-auto-compact.md` (compaction trigger formula, on
the unmerged `research/opencode-auto-compact` branch — merge or
cherry-pick before relying on it).
- Live config: `~/.config/opencode/opencode.json` on this dev machine
carries the real `litellm` provider block, model default, and compaction
settings — see Decisions so far below.
- Current backend facts: `docker-compose.yml`'s `llama-server` runs with
`--ctx-size ${LLAMA_CTX_SIZE:-131072}` (merged via #30); litellm's
`max_tokens` is 16384. opencode reaches the model only through litellm,
per issue #15.
- Invoke `/research` for opencode-internals questions, `/grilling` +
`/domain-modeling` for decisions.
## Decisions so far
- [How does opencode's auto-compact actually work?](https://git.arthurerlich.de/haylan/LLM-Server/issues/27) —
single global `compaction` block, triggers at `usedTokens >= limit.context - min(20000, limit.output)`,
silently disabled if `limit.context` is unset. Findings: `docs/research/opencode-auto-compact.md`
on branch `research/opencode-auto-compact`.
- [Should context/output limits be generated or hand-maintained?](https://git.arthurerlich.de/haylan/LLM-Server/issues/28) —
hand-maintained, no generator script: values live in `~/.config/opencode/opencode.json` with a
comment pointing at the source-of-truth files to check by eye when they change.
- [Point opencode at litellm.home with a virtual key](https://git.arthurerlich.de/haylan/LLM-Server/issues/29) —
done. Provider block added, set as opencode's default model, smoke-tested end to end. Surfaced a
live bug in the process: `LITELLM_MASTER_KEY` doesn't start with `sk-`, so litellm rejects it on
every API endpoint — blocks minting new virtual keys via the documented API flow until fixed.
- **Context bumped to 128K end to end**: `LLAMA_CTX_SIZE` raised 65536 → 131072 on the server
directly, `ctx-size-128k` branch merged into `main` (PR #30) so the repo's checked-in default now
matches, and `~/.config/opencode/opencode.json`'s `limit.context` updated to match — all three
reconciled, re-smoke-tested.
## Not yet specified
- Whether litellm's request-priority/caching (`router_settings`) has any interaction with opencode's
own context bookkeeping.
- Whether the `LITELLM_MASTER_KEY` sk-prefix bug (found while resolving #29) is worth its own fix —
not yet a ticket; small enough it may just get fixed inline whenever someone's next in
`litellm-config.yaml`/`.env`.
## Out of scope
- Tool-calling reliability of Qwen3.8-27B against llama.cpp/opencode (broken llama.cpp Jinja/tool-
parser bugs, documented in `docs/research/opencode-cli-setup.md` §4-5 and
`docs/research/qwen3.8-27b-tool-calling.md`) — orthogonal to context-size/compaction.
- opencode's `websearch` tool for the local model: confirmed unavailable by opencode's own design
(hosted-provider-only, or a paid Exa/Parallel key) — not something this stack's config can turn
on. User chose to leave it off rather than build an MCP bridge to this repo's SearXNG endpoint or
bring in a paid third-party search API.
limit.context in ~/.config/opencode/opencode.json bumped 65536 -> 131072: the server's live LLAMA_CTX_SIZE was changed directly on the box, ahead of merging the ctx-size-128k branch into this repo. Re-smoke-tested (opencode run round-trip), works. Repo's docker-compose.yml/.env.example still show the old default until that branch/PR is merged — worth reconciling so the checked-in default matches what's actually deployed.
`limit.context` in ~/.config/opencode/opencode.json bumped 65536 -> 131072: the server's live LLAMA_CTX_SIZE was changed directly on the box, ahead of merging the ctx-size-128k branch into this repo. Re-smoke-tested (`opencode run` round-trip), works. Repo's docker-compose.yml/.env.example still show the old default until that branch/PR is merged — worth reconciling so the checked-in default matches what's actually deployed.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Destination
opencode (pointed at http://litellm.home, model
qwen3.8-27b-local) usescorrect context-window and compaction behavior for the deployed
llama.cpp/Qwen3.8-27B backend — with those numbers derived from this
repo's existing config (
LLAMA_CTX_SIZE, litellm'smax_tokens) ratherthan hand-duplicated and drifting in
opencode.json. opencode's providerconfig (
limit.context/limit.output) has no documented runtimeauto-discovery (confirmed in
docs/research/opencode-cli-setup.md§5) —so "auto-discovery" here means deciding how much of that gap this repo
closes with its own tooling (a generator script, docs, or just accepted
manual upkeep) vs. leaving it manual.
Notes
CONTEXT.md/docs/adr/don't exist in this repo— proceed silently per
docs/agents/domain.md).docs/research/opencode-cli-setup.md(opencode config shape),docs/research/qwen3.8-27b-quant.md(KV-cache/VRAM math), anddocs/research/opencode-auto-compact.md(compaction trigger formula, onthe unmerged
research/opencode-auto-compactbranch — merge orcherry-pick before relying on it).
~/.config/opencode/opencode.jsonon this dev machinecarries the real
litellmprovider block, model default, and compactionsettings — see Decisions so far below.
docker-compose.yml'sllama-serverruns with--ctx-size ${LLAMA_CTX_SIZE:-131072}(merged via #30); litellm'smax_tokensis 16384. opencode reaches the model only through litellm,per issue #15.
/researchfor opencode-internals questions,/grilling+/domain-modelingfor decisions.Decisions so far
single global
compactionblock, triggers atusedTokens >= limit.context - min(20000, limit.output),silently disabled if
limit.contextis unset. Findings:docs/research/opencode-auto-compact.mdon branch
research/opencode-auto-compact.hand-maintained, no generator script: values live in
~/.config/opencode/opencode.jsonwith acomment pointing at the source-of-truth files to check by eye when they change.
done. Provider block added, set as opencode's default model, smoke-tested end to end. Surfaced a
live bug in the process:
LITELLM_MASTER_KEYdoesn't start withsk-, so litellm rejects it onevery API endpoint — blocks minting new virtual keys via the documented API flow until fixed.
LLAMA_CTX_SIZEraised 65536 → 131072 on the serverdirectly,
ctx-size-128kbranch merged intomain(PR #30) so the repo's checked-in default nowmatches, and
~/.config/opencode/opencode.json'slimit.contextupdated to match — all threereconciled, re-smoke-tested.
Not yet specified
router_settings) has any interaction with opencode'sown context bookkeeping.
LITELLM_MASTER_KEYsk-prefix bug (found while resolving #29) is worth its own fix —not yet a ticket; small enough it may just get fixed inline whenever someone's next in
litellm-config.yaml/.env.Out of scope
parser bugs, documented in
docs/research/opencode-cli-setup.md§4-5 anddocs/research/qwen3.8-27b-tool-calling.md) — orthogonal to context-size/compaction.websearchtool for the local model: confirmed unavailable by opencode's own design(hosted-provider-only, or a paid Exa/Parallel key) — not something this stack's config can turn
on. User chose to leave it off rather than build an MCP bridge to this repo's SearXNG endpoint or
bring in a paid third-party search API.
limit.contextin ~/.config/opencode/opencode.json bumped 65536 -> 131072: the server's live LLAMA_CTX_SIZE was changed directly on the box, ahead of merging the ctx-size-128k branch into this repo. Re-smoke-tested (opencode runround-trip), works. Repo's docker-compose.yml/.env.example still show the old default until that branch/PR is merged — worth reconciling so the checked-in default matches what's actually deployed.