fix: auto-start queued generation jobs on create - #2
Open
jharris1679 wants to merge 1 commit into
Open
Conversation
The backend only dispatches a generation job's worker when a client
opens the SSE stream at /api/v1/semantic/jobs/{id}/stream. The UI does
this automatically after create; the CLI's `generation start` returned
the queued JobResponse and exited, so jobs sat QUEUED indefinitely
until somebody opened the stream.
After a successful create, fire a one-shot fetch to the stream URL and
abort as soon as the first chunk arrives. That's enough for the server
to dispatch the worker without the CLI buffering or printing the event
stream. Errors during the kick are swallowed so a create still appears
successful even if the stream endpoint is briefly unavailable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The backend only dispatches a generation job's worker when a client opens the SSE stream at `/api/v1/semantic/jobs/{id}/stream`. The UI does this automatically after create; the CLI's `generation start` returned the queued `JobResponse` and exited, so CLI-created jobs sat `QUEUED` indefinitely until somebody opened the stream from elsewhere (UI or a manual `generation stream` call).
This PR makes `generation start` fire a one-shot fetch to the job's stream URL after a successful create and abort as soon as the first chunk arrives — enough for the server to dispatch the worker without the CLI buffering or printing the event stream.
Repro
Before #1:
```
$ answerlayer generation start --data '{"connection_id":"…","component_type":"measures"}'
{ "id": "…", "status": "queued", … }
$ sleep 30 && answerlayer generation status
{ "status": "queued" } # still queued forever
```
After:
```
$ answerlayer generation start --data '{"connection_id":"…","component_type":"dimensions"}'
{ "id": "2ea6e5d9-…", "status": "queued", … }
$ answerlayer generation status 2ea6e5d9-…
{ "status": "running", "progress_summary": { "tools_used": 4, … } }
```
Test plan
Follow-ups
This is a workaround for a backend design choice — the queue only runs on SSE attach. A more durable fix is to start the worker on POST. Tracking separately.