[GH-ISSUE #5155] [Feature]: Queue agent work per turn without blocking swipes or roleplay continuation #2850

Closed
opened 2026-10-21 05:56:53 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @SpicyMarinara on GitHub (Aug 16, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5155

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

When post-processing or parallel agents are still working on a generated response, users must currently wait before generating a new swipe or continuing their roleplay.

The current flow keeps one chat-wide generation/agent lock active until the server has awaited parallel agents and completed post-processing. Consequently, even after the base assistant response is durably saved, the UI still blocks:

  • generating another swipe;
  • sending the next roleplay turn;
  • using Continue to request another response.

That wait is unnecessary for a new swipe. A swipe is generated from the same base state as the previous swipe, so unfinished agent output from the previous swipe would not be included in the new generation anyway.

Users should also be able to continue their roleplay once the base response is complete, without waiting for non-blocking parallel or post-processing work. Unfinished results can complete afterward and become available to later turns, but must remain owned by the turn and swipe that triggered them.

The critical concurrency risk is ownership: when a user starts another generation while older agents are still running, those older results must never be saved onto whichever message or swipe happens to be active when the agent finishes.

Proposed solution

Replace the chat-wide agent lock with per-generation, per-message, and per-swipe agent work ownership.

Once the base assistant message is durably saved, allow new swipe generation, the next roleplay turn, and Continue to start while parallel and post-processing agents for the previous response continue in the background.

Queue and persist every agent run against an immutable turn/message/swipe anchor captured when that run begins, rather than resolving its target from the currently active message or swipe when it completes.

Expected behavior:

  • The Swipe action remains available while parallel or post-processing agents are running for the previous response.
  • The roleplay input and Continue action become available as soon as the base response is complete.
  • Starting a new swipe or roleplay generation does not cancel or restart older agent runs.
  • Older agent runs finish normally and save their output only to the exact turn, message, and swipe that triggered them.
  • A newly generated swipe or roleplay response starts its own parallel and post-processing agent pipeline.
  • Multiple in-flight pipelines cannot overwrite, re-anchor, append results to, or clear the processing state of one another.
  • Completion or failure in one pipeline does not block generation or agent processing for another pipeline.
  • Pre-generation work that the current response genuinely depends on can still block that response.
  • UI processing indicators and cancellation target the relevant generation or anchored agent run instead of treating the entire chat as one undifferentiated job.

For a roleplay continuation started before older agents finish, the new generation should use the durable chat state available when it begins. The older agents' eventual output must still be saved to their original anchor, never retroactively injected into or attached to the already-running continuation.

Alternatives considered

  • Keep blocking all chat interaction until every agent finishes. This is safe but creates unnecessary delays after the response itself is ready.
  • Allow swipes but continue blocking ordinary roleplay progression. This leaves the same avoidable delay for users who want to send the next turn or use Continue.
  • Cancel older agents when a new generation starts. This discards work the user still expects to be saved with the previous response.
  • Save results to the currently active message or swipe. This is unsafe because changing swipes or continuing the chat while an agent is running can attach output to the wrong response.

Additional context

The desired lifecycle is:

  1. Response A finishes base generation and starts or continues its parallel/post-processing agents.
  2. The user immediately requests Swipe B, sends the next roleplay turn, or uses Continue.
  3. Response A's agents continue and save only to Response A's original message/swipe anchor.
  4. The new response finishes base generation and starts its own agent pipeline.
  5. Both pipelines complete independently, with every result attached to the correct turn and swipe.

This should apply wherever message swipes, roleplay continuation, and parallel or post-processing agents are supported.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @SpicyMarinara on GitHub (Aug 16, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5155 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? When post-processing or parallel agents are still working on a generated response, users must currently wait before generating a new swipe or continuing their roleplay. The current flow keeps one chat-wide generation/agent lock active until the server has awaited parallel agents and completed post-processing. Consequently, even after the base assistant response is durably saved, the UI still blocks: - generating another swipe; - sending the next roleplay turn; - using Continue to request another response. That wait is unnecessary for a new swipe. A swipe is generated from the same base state as the previous swipe, so unfinished agent output from the previous swipe would not be included in the new generation anyway. Users should also be able to continue their roleplay once the base response is complete, without waiting for non-blocking parallel or post-processing work. Unfinished results can complete afterward and become available to later turns, but must remain owned by the turn and swipe that triggered them. The critical concurrency risk is ownership: when a user starts another generation while older agents are still running, those older results must never be saved onto whichever message or swipe happens to be active when the agent finishes. ## Proposed solution Replace the chat-wide agent lock with per-generation, per-message, and per-swipe agent work ownership. Once the base assistant message is durably saved, allow new swipe generation, the next roleplay turn, and Continue to start while parallel and post-processing agents for the previous response continue in the background. Queue and persist every agent run against an immutable turn/message/swipe anchor captured when that run begins, rather than resolving its target from the currently active message or swipe when it completes. Expected behavior: - The Swipe action remains available while parallel or post-processing agents are running for the previous response. - The roleplay input and Continue action become available as soon as the base response is complete. - Starting a new swipe or roleplay generation does not cancel or restart older agent runs. - Older agent runs finish normally and save their output only to the exact turn, message, and swipe that triggered them. - A newly generated swipe or roleplay response starts its own parallel and post-processing agent pipeline. - Multiple in-flight pipelines cannot overwrite, re-anchor, append results to, or clear the processing state of one another. - Completion or failure in one pipeline does not block generation or agent processing for another pipeline. - Pre-generation work that the current response genuinely depends on can still block that response. - UI processing indicators and cancellation target the relevant generation or anchored agent run instead of treating the entire chat as one undifferentiated job. For a roleplay continuation started before older agents finish, the new generation should use the durable chat state available when it begins. The older agents' eventual output must still be saved to their original anchor, never retroactively injected into or attached to the already-running continuation. ## Alternatives considered - Keep blocking all chat interaction until every agent finishes. This is safe but creates unnecessary delays after the response itself is ready. - Allow swipes but continue blocking ordinary roleplay progression. This leaves the same avoidable delay for users who want to send the next turn or use Continue. - Cancel older agents when a new generation starts. This discards work the user still expects to be saved with the previous response. - Save results to the currently active message or swipe. This is unsafe because changing swipes or continuing the chat while an agent is running can attach output to the wrong response. ## Additional context The desired lifecycle is: 1. Response A finishes base generation and starts or continues its parallel/post-processing agents. 2. The user immediately requests Swipe B, sends the next roleplay turn, or uses Continue. 3. Response A's agents continue and save only to Response A's original message/swipe anchor. 4. The new response finishes base generation and starts its own agent pipeline. 5. Both pipelines complete independently, with every result attached to the correct turn and swipe. This should apply wherever message swipes, roleplay continuation, and parallel or post-processing agents are supported. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2850
No description provided.