Porting chat history to Agent Completions: assistant turns fail
Sume Agent Completions take OpenAI-style messages but return 400 on any assistant turn and start each call in a new thread. What to send instead.

If you send an OpenAI-style conversation to POST /v1/agent/completions with a prior assistant message in the array, the API rejects it with 400 invalid_request. It does not ignore the turn. The docs give the reason: accepting assistant turns would imply that Sume replays a prior conversation, and this endpoint does not do that today.
Each completion also runs in a new thread. thread_id appears in the receipt, but you cannot pass it back to continue. So a chat client has to collapse its history into the current task.
What to send
Use system and user turns only, or a single instruction string. Send exactly one of instruction or messages. Sume joins the turns in order into one prompt. content may be a string, an OpenAI-style [{type: "text"}] array, or input_text and input_image parts.
Put prior context into the user message as text you control, and put bulky data in input, which Sume writes to a workspace file and treats as data, not instructions. That keeps a pasted transcript from being read as new orders.
| You send | Result |
|---|---|
| system and user turns | Joined in order into one prompt |
| An assistant turn | 400 invalid_request |
| Both instruction and messages | 400 invalid_request |
| thread_id | Not supported; each call starts a new thread |
| input_image parts or attachments | Up to 30 images the agent can see |
| stream: true or choices[] expectation | Not available; response is an agent.run receipt |
A rewrite pattern
Summarize the earlier turns in your own code, then send one user message that states the current ask and the relevant facts. For tasks that must remember state across calls, store the state yourself and pass it in input, or use a Format with previous_run_id where that fits, since continued Format runs are a separate documented path.
- Strip assistant turns before the call; do not rely on the API to ignore them.
- Set
generation_spend_cap_usd; it is required and has no default. - Poll
status_urlor register a webhook; do not wait for a synchronous answer. - Use
output_schemawhen your code needs fields, not prose.
Why this is not a chat drop-in
The docs say it plainly: this is not a synchronous chat completion. A real agent turn opens a sandbox, calls tools and may generate media, which takes too long for one HTTP request. Plan the integration as a job queue that happens to accept familiar request syntax.
Checklist for the port
List what your chat client sends today: roles, tool messages, images, system prompt, streaming flag. For each, the table above says whether Agent Completions accept it. The usual changes are removing assistant turns, turning streaming into polling or a webhook, and replacing a thread id with your own stored state.
Test with a tiny cap first. A request that includes an unknown top-level field on the Format surface returns unknown_parameter; on this endpoint the documented 400 causes are a missing cap, both or neither of instruction and messages, an assistant turn, a malformed input, or a model other than sume-agent.
Sources
Related posts
More in Developers
- OpenRouter video payload on Sume: drop seed, size, provider.options
Sume /v1/videos follows the OpenRouter shape but rejects seed, size and provider.options with a 400. A Node function that strips them and checks the model id.
- POST /v1/videos status codes: which of 10 are safe to retry
OpenAPI lists 202 plus ten error codes for POST /v1/videos. Which to retry with the same key, which to fix or stop on, a Python classifier and a backoff plan.
- Preflight a mixed 30 s batch: 2 Seedance and 4 Wan needs $49.67
Sum the reserve for two Seedance 2.5 720p clips and four Wan 3.0 720p clips (49,668,000 micros), compare with GET /v1/balance in integers, then submit.
- Fresh Idempotency-Key per proxy call: why a Sume retry bills twice
If your server proxy mints a new Idempotency-Key on every request, a browser retry becomes a second paid Sume job. Forward the client's key instead; TypeScript.
Written by Sume