fix(portal): isolate concurrent A2A tasks#435
Open
LikiosSedo wants to merge 1 commit into
Open
Conversation
A2A runtime events are session-scoped, so overlapping tasks in one context could consume the same stream and corrupt both artifacts. Add a database-backed active-context lease and release it atomically on terminal transitions.\n\nCheckpoint partial artifacts while working and reconcile complete assistant messages so polling, reconnecting, and streaming clients converge.\n\nConfidence: high\nScope-risk: moderate\nTested: npm test; npm run build; targeted A2A and SQLite migration tests
LikiosSedo
marked this pull request as ready for review
July 22, 2026 08:17
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
Prevent overlapping A2A tasks in one context from consuming the same Runtime event stream, and make in-progress artifacts recoverable through polling and reconnects.
Problem
A2A contexts reuse one Runtime session, while task trackers filter
chat.eventonly by session ID. Two non-terminal tasks in the same context could therefore consume the same deltas and terminal event, producing duplicated or mixed artifacts.The task projection also persisted artifact text only at terminal events. A Portal restart could lose already-streamed output, and
message_endcould not repair missing or divergent deltas.Solution
409 CONTEXT_BUSYfor a second non-terminal task in the same(agent, API key, contextId). Sequential calls continue to reuse the same Runtime session.SICLAW_A2A_PROGRESS_FLUSH_MS, default 3s).message_endwith streamed deltas and emitappend: falsewhen a replacement is required.This PR covers the Siclaw Portal A2A backend. Sicore's native Go A2A facade is a separate implementation and needs a separate parity change.
Test Plan
npm test— 232 files, 4537 passed, 2 skippednpm run buildnpx vitest run src/portal/a2a-gateway.test.ts src/portal/migrate-sqlite.test.tsa2a_tasks