feat(decopilot): background slow generate_image as a durable job#3979
Open
pedrofrxncx wants to merge 4 commits into
Open
feat(decopilot): background slow generate_image as a durable job#3979pedrofrxncx wants to merge 4 commits into
pedrofrxncx wants to merge 4 commits into
Conversation
- generate_image background card is terminal (idle), not a permanent spinner - hide the reaction nudge from the transcript via an internal message-metadata flag (model still sees it; useMessagePairs filters it) - throttle per-step running-summary touch to once/min per run to cut KV CAS write amplification + cross-run contention on the shared per-org key - validate the background-tool route input against the generate_image schema instead of forwarding an unvalidated cast - deterministic reaction-message id (workflow replay must not mint a new one) - backfill runningStore in the reactor/registry test fixtures
The "X agents working on N tasks" home badge is an independent feature that got bundled onto this branch. Remove it so the PR is scoped to the background-tool work: deletes the running-threads store + use-running-summary hook, and restores run-reactor, thread/ports storage, constants, the SSE pool, the home page, and the mesh-sdk running-summary types/events to their pre-feature state.
Updated the backgroundToolWorkflow declaration from an export to a const assignment for improved clarity and consistency in the workflow registration process.
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
Backgrounds slow
generate_imagecalls so they no longer freeze the user's turn or the per-thread gate. On the cluster the tool enqueues a durable DBOS workflow (generate → append result → re-enter the thread gate to react) and returns a "started" handle immediately; desktop daemons POST the work back to a fence-authed cluster route.How it works
makeBackgroundable(name, tool, dispatcher)wraps a slow built-in. With no dispatcher (desktop without link, tests) it returns the inner tool unchanged — backgrounding is a cluster capability, not a behavior change everywhere.createBackgroundToolDispatcherenqueuesbackgroundToolWorkflowon a per-org partitioned DBOS queue. Steps:runHeavyTool(memoized — replays don't regenerate a different image) →appendResult(assistant message rendered via the normal generate_image card) →react(re-enter the per-thread gate so the agent acknowledges/continues).createHttpBackgroundDispatcherPOSTs to/api/:org/threads/:threadId/background-tool, authed with the run's temp bearer + run fence token, which runs the same cluster workflow.jobIdis the workflow id.Review fixes included
role:"user"nudge ("…do NOT call generate_image again") would otherwise render as a user bubble. Added aninternalflag to messageMetadata;useMessagePairsfilters it, so the model still sees it but the user doesn't. Round-trips on both v1 (saveMessages) and v2 (PartEmitterfinish anchor).generate_imageschema instead of forwarding an unvalidatedz.unknown()cast.Testing
bun run check— cleanoxlinton changed files — cleanbun testonbackgroundable,decopilot-events,run-registry,thread-gate-workflow— passNotes
apps/mesh/src/tools/connection/create.ts(an unrelatedON_MCP_CONFIGURATIONfirstRun change) is left out of this PR.main; the running-threads removal restores files to their pre-feature state, so amainmerge/rebase is still pending separately.