[proxy 04/13] models.py: logical-model registry with per-model num_ctx #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec: this implements ONE small step of #2 (the locked reliability-proxy build, aosh leg 04). Do not redesign. Stay tightly scoped to this single step.
Before you start:
git checkout main && git pullso you build on the latest landed step.Fill in
app/models.py- the backend registry. This is data, no I/O.LOGICAL_MODELSmapping logical name ->{"backend_url": str, "ollama_tag": str, "num_ctx": int}.settings.ollama_base_url):fast-think-> num_ctx 49152 (Qwen3-A3B, proven safe in leg 01)fast-> 32768ctx-think-> 32768ctx-> 32768tune-> 32768get_model(name) -> dictthat raisesKeyError/returns None for unknown names, andlist_models() -> list[str].Acceptance:
uv run python -c "from app.models import get_model; print(get_model('fast-think')['num_ctx'])"prints 49152. Add a pytest.When done:
pre-commit run --all-files(or the repo's gate) must pass, commit your work, and push to canonicalmain(this is an ephemeral feature container - finish the merge, do not leave it for a human).docs/FEATURES.mdfromplannedtolandedfor this feature, in the same push.ward agent engineer coilyco-flight-deck/agent-proxy#9 --driver goose🔒 Reserved by
ward agent --driver claude— containerengineer-claude-agent-proxy-8on hostkais-macbook-pro-2.localis carrying this issue (reserved 2026-07-02T16:43:32Z). Concurrentward agentruns are blocked until it finishes or the reservation goes stale (2h0m0s TTL);--forceoverrides.— Claude (she/her), via
ward agentWARD-OUTCOME: done - added the flat-dict
get_model/list_models/LOGICAL_MODELSAPI over the existing registry; landed on main as4b6d962.The surprise here was that
app/models.pyhad already evolved well past this step's spec - a fullRegistry/LogicalModeldesign with fallback chains and dialect adapters was landed, but the small flat{backend_url, ollama_tag, num_ctx}contract this step actually names (and its acceptance test) simply didn't exist yet. So rather than write the naive dict the issue literally describes, I addedget_model/list_models/LOGICAL_MODELSas a thin facade over the registry's primary backend. That keeps the richer design intact and still makes the acceptance (get_model('fast-think')['num_ctx'] == 49152) pass. Felt like the right call under 'don't redesign', but it's a judgement call worth a second look.Two things fought back: the box's backing disk was 100% full, so the first commit died with ENOSPC (retried fine), and
mainmoved under me twice from concurrent sibling runs - rebased cleanly both times. Confident in the result: 50 tests green including a newtest_models.py. The next step (#9) was already reserved and in fact already landed by another run, so my dispatch correctly declined. One rough edge to flag: defaultblackwants to reflow pre-existing lines inmodels.py(the repo clearly uses a wider line length than black's 88 default and ships no black config), so the formatter story is a little ambiguous -ruffis the real gate and it passes. Might be worth pinning a[tool.black]line-length to match ruff.