Skip to content

[Bug]: Fresh-runtime denied ConfirmResult leaves the session stuck in PERMISSION_ASKING #3619

Open

Description

@richuV

Problem

When an agent turn suspends on a permission question, the ASKING state is persisted in AgentState and survives a process restart — that part is great.

On a fresh runtime (post-restart, no live suspended stream):

  • Resuming with an approved ConfirmResult continues the tool call correctly — the session exits PERMISSION_ASKING.
  • Resuming with a denied ConfirmResult does not exit PERMISSION_ASKING. The denial is consumed (or dropped), but the session keeps reporting the same pending question, so the next user message still sees the agent as waiting on a decision that was already given.

In other words: durable approval continuation works; durable denial continuation does not.

Why it matters

Deny is a first-class decision. A host that restart-recovers pending approvals (from AgentState ASKING + the stored tool-call/reply identity) can safely resume approvals, but must special-case denials — and today there is no official path that both consumes the denial and terminates the asking state. The result is either a stuck session (must be abandoned) or a hand-rolled state edit that fights the runtime's ownership of AgentState.

This was previously reported for same-process denials in #3097 (denied tool calls emitted no tool-result events) — this is the fresh-runtime counterpart.

Requested seam

A typed continuation path where a denied ConfirmResult on a fresh runtime:

  1. Validates against the persisted ASKING record (reply identity + tool-call ids),
  2. Emits the denial as a tool-result (consistent with the fixed Permission HITL: user-denied tool calls emit no tool-result events (rule-denied ones do)[Bug]: #3097 behavior),
  3. Transitions the session out of PERMISSION_ASKING so normal input resumes.

We track this upstream-gated as SCHEDULER_HITL_DENIAL_RECOVERY; our host-side workaround (denial replay through the persisted-ASKING continuation path) is documented for removal once the seam lands.

Activity

  1. Shawrange commented on Nov 22, 2026

    @Shawrange

    I'd like to take this issue.
    I traced it on main (b5159827f) to two coupled gaps in ReActAgent.CallExecution:

    1. applyConfirmResults() transitions approved ToolUseBlocks out of ToolCallState.ASKING (ALLOWED), but leaves denied ToolUseBlocks in ToolCallState.ASKING in persisted AgentState.context.
    2. askingToolCalls() filters lastAssistantMessage solely by ToolCallState.ASKING without checking MessageUtils.pendingToolUseIds(...), so denied calls can remain reported as PERMISSION_ASKING across fresh-runtime recovery, stop-on-denial middleware, partial denial, or mixed deny + external suspension.
      I plan to submit a surgical fix updating denied ToolUseBlock state in applyConfirmResults(), adding pending-ID filtering in askingToolCalls() for defense in depth (including legacy persisted states), and adding offline JUnit 5 regression tests across AgentStateStore and ThreadJournalStore. Let me know if it's still open for a PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions