Skip to content

fix: unrecoverable interruption error System message must be at the beginning #349

@avoidwork

Description

@avoidwork

Summary

Interruptions sometimes fail unrecoverably with a 400 error stating "System message must be at the beginning." This prevents the agent from continuing after an interruption is triggered.

Environment

  • OS: Linux 7.0.2-7-pve
  • Node.js: v25.8.1
  • madz version: 1.11.0
  • LLM provider: Unknown — user to confirm

Reproduction

Steps to reproduce the behavior:

  1. Trigger an interruption during agent execution
  2. Observe the connection attempt to resume
  3. Error occurs and process becomes unrecoverable

Expected Behavior

The interruption should be handled gracefully, allowing the connection to be re-established and execution to continue or fail cleanly with a recoverable error.

Actual Behavior

The connection attempt fails with an unrecoverable error: "I couldn't connect right now - 400 System message must be at the beginning.. Try sending your message again?"

Additional Context

The error message indicates a malformed request payload where the system message is not positioned correctly at the start of the message array. This suggests a bug in how interruption context is reconstructed before sending the next request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions