Skip to content

[Bug]: User messages sent together with a permission-HITL resume are silently dropped #3294

Open

Description

@xuchaoguo1983

AgentScope-Java Version

2.0.3

Description

When a run is paused on permission HITL (a tool call in ASKING state), an AG-UI request that carries both a resume[] entry answering the interrupt and a new user message in messages succeeds. However, the new user message is silently dropped: it never enters the agent context, in this turn or in any later turn, and no error is raised.

Why (2.0.3)

  • AguiMessageConverter.toMsgList(RunAgentInput, …) returns the new user messages followed by the confirm-result message.
  • In ReActAgent, when askingToolCalls() is non-empty, the call goes to validateAndAcceptConfirmResults(msgs, asking) and then to resumeAgent(). That branch only extracts ConfirmResults from msgs. The remaining messages are never passed to addToContext.

Reproduction (verified on 2.0.3, AG-UI server + Redis state store)

  1. Send a user message. The model calls a tool that requires confirmation, and the run finishes with an interrupt.
  2. Send one request with messages = [...history, {role: user, content: "second message"}] and resume = [{interruptId, status: resolved, payload: {approved: false}}].
    • Actual: the tool is denied, and the model replies only to the denial. "second message" is absent from the model request, and it is also absent in the next turn.
    • For comparison: sending only the new message (no resume) is rejected with Thread has unresolved interrupts; RunAgentInput.resume must address all of them.

Expected

Either option would avoid silent loss of user input:

  • append the new user messages after the tool results, and let the model answer them in the same turn (a common UX: typing a new message cancels the pending approval); or
  • reject the request with a clear error, like the no-resume case.

Related: #3135 (orphaned ASKING state has no graceful path).

Activity

  1. oss-maintainer commented on Sep 25, 2026

    @oss-maintainer
    Collaborator

    Issue Evaluation

    Category: bug / area/core/agent (permission HITL resume path) | Status: Confirmed | Severity: high

    Verified against main @ ea78c3172 by static read of the current source — both claims in the report hold, and the behaviour is still present at HEAD (not fixed by c5db8f72 / #3100, which covered tool results, not user messages).

    Claim-by-claim check

    Claim Result Evidence
    AguiMessageConverter.toMsgList(RunAgentInput, …) returns new user messages followed by the confirm-result message TRUE agentscope-extensions/.../agui/converter/AguiMessageConverter.java:207 seeds the list with toMsgList(input.getMessages()), then :217-218 appends toConfirmResultMsg(...) per resolved interrupt and returns at :224. The ordering is already asserted upstream by AguiMessageConverterTest.java:1105-1108 (index 0 = non-confirm message, index 1 = METADATA_CONFIRM_RESULTS), and the delivery path keeps both: AguiAgentAdapter.java:150-152 → AguiRequestProcessor.java:340-343,362
    In ReActAgent, the askingToolCalls()-non-empty branch consumes only ConfirmResults and never calls addToContext for the rest TRUE ReActAgent.java:1857-1861 → validateAndAcceptConfirmResults(msgs, asking); return resumeAgent();. validateAndAcceptConfirmResults (:1966-2039) extracts via extractConfirmResults (:1936-1955, reads only Msg.METADATA_CONFIRM_RESULTS) then applyConfirmResults (:2101-2144), which only flips ToolUseBlock states (:2130) and appends DENIED tool results (:2141). resumeAgent() (:2405-2407) is acting(0) — it takes no messages. addToContext (:2386-2390) is reached only at :1851 (no pending tools) and :1870 (recovery path)
    No error is raised, and the loss persists across turns TRUE The throw at ReActAgent.java:1973-1994 fires only when zero ConfirmResults are found, so extra user messages are silently ignored; doCall → saveStateToSession (:1241) persists only state.contextMutable(), so the message is absent from the model request in this turn and in every later turn

    Impact. ReActAgent is the bug site and HarnessAgent.java:173 delegates to it, so every deployment on a persistent AgentStateStore (Redis / JSON / JDBC) that drives the documented resume flow (docs/v2/en/docs/building-blocks/permission-system.md, "HITL integration" step 4: build ConfirmResults and attach them to the resume message — the doc does not say other messages may share that request, which is why the silent drop is not covered by any contract) loses user input silently. Same class of defect as #3291 (silent loss of in-code intent for a session) and adjacent to #3135, which the reporter links.

    Root cause. The ASKING branch treats the incoming message list as a pure ConfirmResult carrier. Once it finds the resume payload, the rest of the request is discarded without error, because context append and interrupt resolution are two mutually exclusive code paths instead of two steps of one turn.

    Fix direction — we support option A of the two the reporter proposes, with one ordering constraint. Append the non-ConfirmResult messages instead of dropping them, but not immediately before resumeAgent(): the resume's tool results are written by acting(0), so persisting a user message first puts a user turn between an assistant tool_use and its tool_result, which strict providers reject. The append belongs after the pending tool results are materialised (before the next reasoning iteration). Partition by METADATA_CONFIRM_RESULTS / ToolResultBlock so the existing approved / denied / mixed batches are unaffected. Option B — reject the request with a clear error symmetric to ReActAgent.java:1973-1994 and the AG-UI "unresolved interrupts" rejection — is acceptable as a fallback that removes the silent-loss property, but keeps the known UX broken.

    Reproduction. Deterministic, unit-testable, no external services: reach ASKING, then call agent.call(List.of(userMsg, confirmMsg)).block() and assert the user text appears in the next model request / getAgentState().getContext(). Gaps to close: ReActAgentHitlTest.java's ScriptedModel (line 74) discards the messages argument, so it must capture them to make the assertion meaningful; AguiPermissionResumeTest.java:71 currently resumes with an empty messages list — add a user message there to cover ReActAgent and HarnessAgent, official-resume and direct-ConfirmResult paths.

    Caveats. Static review only — nothing was compiled or executed here, so the runtime claim ("absent in the next turn too") rests on the persistence path read at ReActAgent.java:1241, not on an observed run. We also note the same branch drops a CopilotKit dual-path role:"tool" message sent alongside a resume (AguiMessageConverterTest.java:1073-1109); the confirm message supersedes it there, so it is out of scope for this fix.

    Next step: no open PR is linked to this issue, so we will not auto-generate a competing patch unless the reporter wants one. If a fix should be generated by us, reply /approve and a spec + PR will follow; otherwise @xuchaoguo1983 is welcome to take it — the two-line partition and the placement constraint above are the whole change.


    Automated evaluation by github-manager-bot

  2. added
    bug
    area/core/agent
    on Sep 25, 2026
  3. Ashfaqbs commented on Sep 25, 2026

    @Ashfaqbs

    I'd like to take this one, following the evaluation's option A: append the non-ConfirmResult messages after the pending tool results are materialised (before the next reasoning iteration), partitioned by METADATA_CONFIRM_RESULTS. I'll add the deterministic ReActAgent test (capturing the model's messages) plus the AG-UI resume case with a user message. Will open a PR shortly.

  4. impartshadow commented on Sep 26, 2026

    @impartshadow

    This is a silent-input-drop: a request carrying two kinds of payload had only one consumed, and no error was raised.

    My read is that the askingToolCalls() branch in ReActAgent treats msgs as if it contained only confirm results. The issue says the branch "only extracts ConfirmResults from msgs", and toMsgList returns "the new user messages followed by the confirm-result message". So the branch splits off the confirm result, calls resumeAgent(), and discards everything else. The converter and the agent disagree about what msgs holds on the resume path. Nothing checks that the two sides agree, so the disagreement stays hidden. The no-resume case is rejected with Thread has unresolved interrupts, which suggests the guard exists at the AG-UI layer but only checks that the interrupts are addressed. It doesn't check that the rest of the input is consumed.

    The check I'd add is a conservation assertion at the validateAndAcceptConfirmResults boundary. Before it returns, partition msgs into confirm-result messages and everything else. If the "everything else" set is non-empty, either every message in it must appear in the context handed to resumeAgent(), or the call must throw. As a regression test: paused thread, request with resume plus one user message, then assert the model request contains "second message" or that the call fails. The current code does neither. A second assertion belongs in the AG-UI layer: the count of inbound user messages not already in the thread history must equal the count added to the context.

    I'm not certain of the exact split point. I haven't run 2.0.3, so a debug dump of msgs entering validateAndAcceptConfirmResults would confirm it. If the user message is present there and absent from addToContext, the hypothesis holds. If it is already gone by then, the loss happens in the converter or the state store.

    Advisory SFA-2026-46395B0CF9 · Full redacted write-up: https://impartshadow.github.io/echo-site/failure-cases/bug-user-messages-sent-together-with-a-permission-hi-46395b0cf9.html
    If this diagnosis is useful, react 👍 to this comment; if it is wrong, react 👎 — I use the verdict to choose what I investigate next.

  5. oss-maintainer commented on Sep 28, 2026

    @oss-maintainer
    Collaborator

    Status: 72 h feedback window expired — no automated PR will be generated, the proposal window here is closed

    The evaluation above (5834654212, posted 2026-09-25T15:06:27Z) reached its 72-hour feedback limit at 2026-09-28T15:06:27Z. No reply on this thread starts with an approve, revise or reject command, so per our workflow we skip PR generation and no competing PR will be filed from this proposal window.

    This is a timing call only — the fix path here is already community-owned and was claimed in writing. @Ashfaqbs replied 2026-09-25T16:05:23Z ("I'd like to take this one, following the evaluation's option A: append the non-ConfirmResult messages after the pending tool results are materialised"), and opened PR #3295 (fix(agent): keep user messages sent with a permission-HITL resume), which is still OPEN and unmerged at head e706863e07 with reviewDecision=APPROVED. The change ships through that PR, not through a bot-generated duplicate. @impartshadow's reply 2026-09-26T06:31:24Z is a technical analysis of the askingToolCalls() branch in ReActAgent, not a directive; it is read as part of the thread, and nothing in it requires action from us.

    One thing worth handing to whoever merges #3295: the analysis in 5843918844 argues the drop is silent because the pending-tool-results materialisation consumes only the ConfirmResult payload, and PR #3295 covers that path. If a reviewer wants coverage of the same seam for a resume sent with no pending interrupt at all, a test on that branch is the smallest addition — it is a question for the PR, not for this issue, and no action is needed here.

    Automated by github-manager-bot

  6. impartshadow commented on Sep 28, 2026

    @impartshadow

    Scoped answer after reading e706863e: a resume sent with no open interrupt is already fail-closed, not another silent-loss branch. AguiResumeCoordinator.validate() returns RunAgentInput.resume does not match any open interrupt, and the processor emits AGUI_INTERRUPT_CONTRACT_ERROR. I would not add that case to #3295 or hold this fix for it.

    The bounded remaining vector is the protocol path that reproduces #3294 itself:

    1. In AguiPermissionResumeTest, make the first run reach permission ASKING.
    2. Resume with both the valid AguiResume and one new AG-UI user message ("second message").
    3. Capture the next model request and assert:
      • the resumed tool result precedes "second message";
      • "second message" appears exactly once;
      • no RUN_ERROR is emitted;
      • the persisted context still contains it after the run.

    That test would verify the converter → coordinator → adapter → ReActAgent seam; the direct core tests in #3295 already prove the agent-side conservation and ordering rule.

    Current technical verdict: merge #3295 as scoped. It is approved, mergeable, CLA-green, and all listed checks are green at e706863e. The AG-UI vector can be a small follow-up if maintainers want protocol-level coverage. Maintainers: please merge, or record the specific technical condition still blocking it so the contribution has an explicit verdict.

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

    area/core/agentbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions