Skip to content

[Bug]: AG-UI extractLatestUserMessage drops tool results, causing "Pending tool calls exist without results" error #1692

@liangxp1990

Description

@liangxp1990

Bug Description

When using AguiRequestProcessor with server-side memory enabled, the extractLatestUserMessage method drops tool result messages from the request. This causes the PendingToolRecoveryHook to report "Pending tool calls exist without results" error when the Agent tries to process subsequent requests.

Steps to Reproduce

  1. Configure agentscope-agui with server-side memory enabled
  2. Send an initial request that triggers tool calls (e.g., "check document")
  3. Agent responds with tool calls, frontend executes them and returns tool results
  4. Send a follow-up user message (e.g., "execute the plan")
  5. Backend throws error: Pending tool calls exist without results

Expected Behavior

The follow-up request should be processed correctly. Tool results from the previous turn should be preserved.

Actual Behavior

The backend throws an error because extractLatestUserMessage only keeps the last user message and discards all tool result messages.

Root Cause

In AguiRequestProcessor.process():

if (agentResolver.hasMemory(threadId)) {
    input = extractLatestUserMessage(input);  // This drops tool results!
}

Suggested Fix

Modify extractLatestUserMessage to preserve tool result messages by collecting them before the last user message.

Environment

  • agentscope-java: 1.0.12
  • Java: 17+

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ext/integrationExternal protocols & middleware integrationsbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions