GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FEATURE]: Allow messages to be sent mid-turn — interrupt, queue, or inject during active generation · Issue #21388 · anomalyco/opencode

[FEATURE]: Allow messages to be sent mid-turn — interrupt, queue, or inject during active generation #21388

New issue
Copy link
New issue
Copy link
Closed
Closed
[FEATURE]: Allow messages to be sent mid-turn — interrupt, queue, or inject during active generation#21388
Copy link
Assignees
thdxr
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)

Description

@dylandru
dylandru
opened on Apr 7, 2026
Issue body actions

Problem

Today, once a turn begins (model is streaming tokens or executing tool calls), the input is effectively frozen. Any message typed by the user is either:

  1. Queued silently and delivered as a new turn after the current one finishes
  2. Discarded in some UI states
  3. Never acknowledged — the user has no feedback about what will happen to it

This creates several painful failure modes:

  • The agent is mid-stream realizing the wrong approach, user can't correct it
  • The agent has started a 15-tool refactor in the wrong directory — no way to redirect without full cancel
  • The user wants to give additional context that changes the trajectory ("actually use the v2 API not v1") but must wait for the entire turn to finish
  • Cancel (Escape/Ctrl+C) is the only option — a blunt instrument that loses all progress

This is distinct from #17691 which proposes a /btw slash command specifically to inject context between tool calls. This issue is about a first-class mid-turn messaging system at the protocol level — covering all phases of a turn.


Desired Behavior

The user's input should always be live. Messages sent during an active turn should be handled in one of three modes (configurable per user / per session):

Mode 1: Queue + Inject at next tool boundary

Message is held and injected into the agent's context at the next natural breakpoint (between tool calls). The current tool finishes. No interruption.

Mode 2: Preempt — pause streaming, inject, resume

The model stream is paused mid-generation. The message is prepended to the pending assistant context and the turn resumes with the new context. Requires SSE stream cancellation + context splicing.

Mode 3: Hard interrupt with context carry-forward

The current turn is cancelled (existing behavior), but the accumulated partial tool results + the new user message are forwarded into a new turn automatically. The user doesn't lose the work done so far.


Proposed UX

┌─────────────────────────────────────────────────────┐
│  Agent is running... [Cancel ✕]  [Inject ↩]         │
│                                                     │
│  > _______________________________________________  │
│    Send mid-turn (injects at next tool boundary)    │
└─────────────────────────────────────────────────────┘
  • Input remains enabled during agent turns (not grayed out)
  • A visual indicator shows the message will be injected, not queued for next turn
  • Optional: show the queued message in the turn timeline as a "pending injection"

Technical Sketch

TUI path:

  • Keep input active at all times
  • On Enter during active turn: push to mid_turn_queue: Message[] on the session
  • Before each tool dispatch in runTurn(), drain mid_turn_queue → append as user messages to the message array
  • Surface queue state in the turn event stream: { type: \"mid_turn_message_queued\", content }

Web path:

  • Same session-level queue, surfaced via SSE event
  • Input stays active, send button changes to "Queue for injection" label during active turn

API path:

POST /session/{id}/message
{
  \"content\": \"actually use the v2 API\",
  \"delivery\": \"inject\" | \"queue\" | \"interrupt\"
}
  • inject: deliver at next tool boundary in current turn
  • queue: deliver as new turn after current completes (existing behavior)
  • interrupt: cancel current turn and start new one with carry-forward context

Why This Matters

This is one of the highest-leverage UX improvements for agentic workflows:

  • Long tasks become steerable instead of all-or-nothing
  • Reduces wasted compute — no more watching a wrong refactor complete before you can correct it
  • Enables collaborative human-in-the-loop workflows where the human and agent work together within a single turn
  • Naturally extends automode — external scripts can inject context mid-loop without cancelling

Related Issues

  • [FEATURE]: /btw command — inject context into agent mid-task without interrupting #17691 — /btw command (subset of this: inject between tool calls only)
  • Interrupted tool calls permanently corrupt session history (orphaned tool_use without tool_result) #21326 — Interrupted tool calls corrupt session history (mid-turn handling must not create orphaned tool_use)
  • [BUG] Input text typed during a pending permission prompt is lost after accepting/rejecting #21320 — Input text lost after permission prompt (related: input state during active turn)
Reacted by softyoda

Activity

  1. github-actions
    assigned
    thdxr
    on Apr 7, 2026
  2. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 7, 2026
  3. dylandru
    closed this as completedon Apr 7, 2026
  4. github-actions commented on Apr 7, 2026

    @github-actions
    github-actionsBot
    on Apr 7, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • [FEATURE]: Support for asynchronous/parallel input during execution #18929: [FEATURE]: Support for asynchronous/parallel input during execution — describes the same core feature: keeping input active during agent execution and injecting messages into the current turn without interrupting it.
    • [FEATURE]: /btw command — inject context into agent mid-task without interrupting #17691: [FEATURE]: /btw command — inject context into agent mid-task without interrupting — a closely related subset of this request (also referenced in your issue).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.