Skip to content

Malformed Message After Tool Request Cancellation #12963

Description

@P3akShadow

Before submitting your bug report

Relevant environment info

- OS:
- Continue version:
- IDE version:
- Model:
- config:
  

  
  OR link to agent in Continue hub:

Description

Bug Report: Malformed Message After Tool Request Cancellation

Summary

When canceling/denying a tool request in Continue, the follow-up message sent to the LLM has a malformed structure where the system message is not at the beginning of the conversation history. This causes a 400 Bad Request error from the LLM provider (via aqueduct proxy).

Error Details

Error: 400 aqueduct.BadRequestError: OpenAIException - Error code: 400 - 
{'error': {'message': 'System message must be at the beginning.', 
'type': 'BadRequestError', 'param': None, 'code': 400}}. 
Received Model Group=qwen-3.5-397b

Steps to Reproduce

  1. Continue attempts to execute a tool (e.g., running a bash command like sage selection/baselines/graph_operations.sage)
  2. User denies/cancels the tool request
  3. Continue sends a follow-up message to the LLM
  4. The LLM provider returns a 400 error indicating "System message must be at the beginning"

Expected Behavior

After canceling a tool request, Continue should:

  • Properly format the conversation history with the system message at the beginning
  • Send a valid message structure to the LLM
  • Gracefully handle the cancellation and allow the user to continue the conversation

Actual Behavior

  • The message structure is malformed
  • System message is not positioned at the beginning of the conversation array
  • The LLM provider rejects the request with a 400 error
  • The conversation is interrupted and cannot continue

Environment

  • Continue Extension: (version unknown)
  • LLM Provider: qwen-3.5-397b (via aqueduct proxy)
  • Proxy Layer: aqueduct
  • Platform: darwin (macOS)
  • Date: 2026-07-09

Additional Context

This appears to be an issue with how Continue constructs the conversation history message array after a tool cancellation event. The system message role should always be the first element in the messages array sent to OpenAI-compatible APIs, but after tool cancellation, this ordering seems to be violated.

Suggested Fix Areas

  1. Review message formatting logic in tool cancellation handlers
  2. Ensure system message is always positioned at messages[0] after any conversation state change
  3. Add validation before sending requests to catch malformed message structures

Workaround

Currently, the only workaround is to restart the Continue chat session after this error occurs.

To reproduce

  1. make a request that runs a tool call
  2. cancel the tool call

Log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsRelates to tool usagekind:bugIndicates an unexpected problem or unintended behavioros:macHappening specifically on Mac

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions