[proxy 13/13] OpenAI surface polish: streaming chat, /v1/completions, /v1/models #17
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.Complete the OpenAI-compatible surface in
app/main.py+app/upstream.py.POST /v1/chat/completionswhenstream: true: stream ollama/api/chat(stream=true) and re-emit as OpenAI SSEchat.completion.chunkevents ending withdata: [DONE].POST /v1/completions: legacy text-completion shape, internally mapped to a single-user-message chat call.GET /v1/models: list the logical names fromapp.models.list_models()in OpenAI{"object":"list","data":[{"id":name,"object":"model"}...]}shape.Acceptance: pytests: /v1/models lists
fast-think; a streaming request yields SSE chunks then [DONE]; /v1/completions returns a completion. This closes the core build of #2 - leave a comment on #2 noting the surface is complete.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.🔒 Reserved by
ward agent --driver claude— containerengineer-claude-agent-proxy-17on hostkais-macbook-pro-2.localis carrying this issue (reserved 2026-07-02T16:45:56Z). Concurrentward agentruns are blocked until it finishes or the reservation goes stale (2h0m0s TTL);--forceoverrides.— Claude (she/her), via
ward agent🔓 Reservation released by
ward container reap— containeragent-proxy(--driver claude) exited without launching the agent (smoke-test death, ward#222/#264), so the hold it took is retracted. A plainward agentretry no longer needs--force.— Claude (she/her), via
ward agent🔒 Reserved by
ward agent --driver goose— containerengineer-goose-agent-proxy-17on host1afbcb384a27is carrying this issue (reserved 2026-07-02T16:48:30Z). Concurrentward agentruns are blocked until it finishes or the reservation goes stale (2h0m0s TTL);--forceoverrides.— Goose, via
ward agent🔒 Reserved by
ward agent --driver claude— containerengineer-claude-agent-proxy-17on hostkais-macbook-pro-2.localis carrying this issue (reserved 2026-07-02T17:47:41Z). Concurrentward agentruns are blocked until it finishes or the reservation goes stale (2h0m0s TTL);--forceoverrides.The pre-flight judged this issue GO for an unattended run. Its justification:
pre-flight read (GO)
Context to front-load: Before the first edit in the clone I will read (1)
app/main.py— the existing route definitions, how the non-streaming/v1/chat/completionsis wired, the FastAPI/response conventions and error shapes already in use; (2)app/upstream.py— how ollama/api/chatis currently called (client, base URL, auth, timeout), so the streamingstream=truepath and the/v1/completions→chat mapping reuse that plumbing rather than reinventing it; (3)app/models.pyfor the exactlist_models()signature and whatfast-thinkresolves to; (4) the existingtests/for the pytest fixtures/style so the three new acceptance tests match convention; (5)docs/FEATURES.mdto find the exactplannedline to flip; and (6) the repo gate (pre-commit/ward verb) plus#2's comment expectations. I will actually open each of these in the fresh clone before editing, not defer them.Main risk: the precise ollama streaming chunk schema and how cleanly the current
upstream.pysupports a streaming generator (async vs sync httpx, whether SSE re-emission needs aStreamingResponsehelper that may not yet exist) — plus whetherfast-thinkandlist_models()are named exactly as the issue assumes. All of that is readable in the clone and fully reversible, the scope is tight and test-anchored, and the only cross-issue action is a comment on #2 (non-destructive). The reservation-release comment is just container-reap bookkeeping and does not change the spec.GO
— Claude (she/her), via
ward agent🔓 Reservation released by
ward container reap— containeragent-proxy(--driver claude) exited without launching the agent (smoke-test death, ward#222/#264), so the hold it took is retracted. A plainward agentretry no longer needs--force.— Claude (she/her), via
ward agentLanded. app/main.py serves streaming and non-streaming /v1/chat/completions, /v1/completions, and /v1/models, covered by tests/test_api.py. Note: /v1/models now lists live ollama tags rather than the logical name fast-think after the alias retirement in #32. Closing as done.