Skip to content

Prevent message queue from draining when tool approvals are pending #61

@KaranJagtiani

Description

@KaranJagtiani

When the agent completes a stream that ends with a tool call requiring approval, the chat interface incorrectly auto-drains queued messages even though it's still waiting for user action. This causes queued messages to interrupt the approval flow, breaking the conversation state and creating race conditions.

Scope

  • UI (ui/src/components/chat/ChatInterface.tsx):
    • Modify the queue-draining useEffect (currently around line 614-627) to check if there are any pending approvals before draining the queue.
    • Add a condition that prevents auto-drain when approvableTools.length > 0.
    • Ensure the effect has access to approvableTools by positioning it after the approvableTools memoized value definition.
    • Update the dependency array to include approvableTools.length.
  • The fix should preserve existing queue behavior: messages should still drain automatically once approvals are resolved and the stream completes.

Acceptance criteria

  • Queued messages remain in the queue when the agent is waiting for tool approval.
  • Once an approval is given and the subsequent agent response completes (with no remaining pending approvals), the queue resumes draining normally.
  • The "Submit now" feature for queued messages continues to work during approval wait states.
  • No regressions to existing queue functionality (FIFO ordering, removal, immediate submission).
  • Attach a screen recording showing the new behavior to demonstrate the fix.

How to test manually

  1. Run the Engine, MCP server, and UI locally (see respective README files).
  2. Start a conversation that triggers a tool call requiring approval (e.g., "Delete the nginx deployment in the default namespace").
  3. While the agent is responding, type and submit another message — it should enter the queue.
  4. Wait for the tool approval prompt to appear.
  5. Verify that the queued message remains in the queue and does not auto-submit.
  6. Approve or deny the tool call.
  7. Wait for the agent's response to complete.
  8. Verify that the queued message now auto-drains and sends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersuiThe Command Center of Skyflo.ai

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions