* feat: add jobs for all operations besides chat completion to the job engine
* fix(jobs): cancellation, format negotiation, and output cap for media job ops
Address review feedback on the new image/audio/3D job ops:
- Propagate cancellation through the Router and backend HTTP request: image
ops bind the request cancel flag (post/post_multipart now abortable) and
streaming audio/3D sinks stop accepting data once cancelled; every op checks
the cancel flag and throws JobError(499, "interrupted").
- audio_speech/audio_generations negotiate and validate response_format against
the backend's supported formats so the returned MIME/response_format match.
- Cap buffered base64 media output (kMaxJobMediaOutputBytes) so a large result
cannot bloat jobs.json.
- Tests: drop the no-op assertion, assert op round-trip, add a no-backend
format-rejection test.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* fix(jobs): forward negotiated audio format and job cancellation to backends
Write the negotiated response_format back into the request for the
audio_speech and audio_generations job ops, so the backend encodes the
format the step output's mime_type reports, including a default the job
never sent.
Bind the job cancel flag as the request cancel token around media job
ops, and pass that token to Trellis' blocking post_multipart() call, so
interrupting a model_3d_generations step aborts the in-flight request
instead of waiting for it to finish.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fix(jobs): bound media storage and stop failed or cancelled operations
* fix(jobs): enforce retained media budget and cancel speech streams
* fix(jobs): count extracted context copies against the media budget
* fix(jobs): count only the growth when an extract replaces a context value
* fix(jobs): catch error payloads in media streams and bound extract values
* fix(http): let GET honour the request cancel token and pass it through ACE-Step
* fix(jobs): track media-derived extract copies per key instead of capping extracts
* fix(jobs): drop a clobbered key from the media-extract tally
* fix(jobs): normalize speech streaming options and image inputs, keep PCM headers
* refactor(jobs): count stored media bytes and keep bookkeeping out of the API view
* fix(jobs): reject non-base64 URIs, pre-check audio models, and avoid JSON round trips
* docs(jobs): move the job-op guide under docs/dev and update the job-system page
* test(jobs): make the media sink testable and cover its failure paths
---------
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
* fix(server): report backend streams that end without any SSE event
A backend that commits 200 text/event-stream, fails internally, then closes
the response cleanly leaves curl reporting CURLE_OK and status 200, so every
error branch in forward_sse_stream() is skipped. The success branch then
synthesizes data: [DONE] and logs "Streaming completed - 200 OK", turning a
failed generation into a well-formed empty stream that a client cannot tell
apart from a model with nothing to say.
#2975 covered the non-200 path, and the CURLE_PARTIAL_FILE / CURLE_RECV_ERROR
branch only fires when the connection is cut abnormally. Emit the same framed
{error: ...} event instead of the synthetic marker when no data event was ever
forwarded, and record the failure in telemetry. A stream that carried events
but omitted [DONE] keeps today's behavior.
Reported by @pdittaro on ds4:rocm in #2826.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01446LcJ87kp9d25twx8oVGa
* fix(server): count an SSE event only once its terminator arrives
has_data_event recognized only "data: " with a space, so a valid
data:{...} stream was misclassified as carrying no event and received a
synthetic error. It also counted a data field on sight, so a stream cut
off after "data: {...}" with no blank line still reported success even
though the client discards an event it never saw terminated.
Accept the optional space the SSE grammar allows, and promote a pending
data field to a delivered event only when a blank line completes it. The
ChatCompletionChunk: framing is not SSE and has no terminator to wait
for, so it still counts on sight.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01446LcJ87kp9d25twx8oVGa
* fix(server): split SSE lines on CRLF and CR, not just LF
process_sse_lines() only recognized LF, so a backend using CR or CRLF
terminators had its data fields forwarded to the client but never counted
as events, and has_data_event then reported a valid stream as empty with a
synthetic 502. A trailing CR is held back until the next chunk shows
whether an LF follows, otherwise a CRLF split across chunk boundaries
would be read as an extra blank line and terminate the event before its
data field arrived; the held CR is released once the transfer ends.
A field name with no colon carries an empty value in SSE, so a bare "data"
line now completes an event as well.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01T2q9CUb6tbg3oNVzP6dXGZ
* refactor(server): parse SSE lines as name/value fields
Matching "data:" and "ChatCompletionChunk: " with literal prefixes and
substr offsets ties the parser to exact spacing, so a backend writing
ChatCompletionChunk:{...} was classified as an empty stream. Deriving the
field name and value from the first colon drops the offsets and makes the
optional space uniform across the streaming and telemetry paths.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RCvveQZDpzFaWa5QhuKaos
---------
Co-authored-by: Claude Opus 5 <[email protected]>