[proxy 06/13] /v1/chat/completions (non-streaming) shaped to OpenAI schema #10
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.Add the OpenAI-compatible chat route in
app/main.py, callingapp.upstream.dispatch_chat.POST /v1/chat/completions: accept the OpenAI request body (model,messages, ignore extras gracefully). Mapmodelto the logical name, calldispatch_chat, and shape the ollama response into the OpenAIchat.completionschema:{"id", "object":"chat.completion", "model", "choices":[{"index":0, "message":{"role":"assistant","content":...}, "finish_reason":"stop"}], "usage":{"prompt_tokens":prompt_eval_count, "completion_tokens":eval_count, "total_tokens":sum}}.Acceptance: a pytest with
dispatch_chatmonkeypatched to return a fake ollama reply asserts the route returns OpenAI-shaped JSON with achoices[0].message.content.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#11 --driver goose🔒 Reserved by
ward agent --driver claude— containerengineer-claude-agent-proxy-10on hostkais-macbook-pro-2.localis carrying this issue (reserved 2026-07-02T16:44:38Z). Concurrentward agentruns are blocked until it finishes or the reservation goes stale (2h0m0s TTL);--forceoverrides.— Claude (she/her), via
ward agentWARD-OUTCOME: done - non-streaming /v1/chat/completions OpenAI shaping was already landed; hardened its acceptance test to the full schema and pushed to main.
Honest retrospective: this step turned out to be already-built. The non-streaming route, the exact chat.completion shaping, and a faked-dispatch acceptance test all landed earlier with the resilience-proxy core (#2), and the FEATURES line already read landed. The issue references
app.upstream.dispatch_chat, but the code evolved past that name - dispatch runs through the queue + resilience layer intoupstream.chat. Rather than redesign backward to invent adispatch_chatshim (which the container doctrine forbids and which would regress the queue path), I stayed scoped: I tightened the existing acceptance test to assert the whole schema this step locks in - assistant role, model echo, choice index, and a usage block where total_tokens == prompt + completion.What fought back: nothing in the code, but the canonical main moved under me twice mid-push (other proxy-step containers landing #9, models/analysis API work), so I fetched-merged-retested-pushed a couple of times. Clean merges, 52 tests green after each.
Confidence is high in the result - the contract is now more strictly pinned and everything's green. Two rough edges worth flagging: (1) the next-step dispatch (
ward agent engineer ...#11) could not run - this daemonless feature container has no Docker socket, socreate siblingfailed; a human or the host loop needs to kick off #11. (2) These granular proxy-step issues are all shadow-boxing an already-complete build, so each is really a verify-and-close pass, not fresh implementation - worth knowing for the rest of the 13.