Skip to content

[BUG] HTTP 400: orphaned tool_result in conversation history due to dual truncation #415

@suxinshuo

Description

@suxinshuo

Pre-checks

Deployment Method

Source (setup.sh)

Steps to Reproduce

  1. Create a session with an agent that has tools enabled.
  2. Send enough messages so that the conversation history contains many tool-call rounds (close to context_window_size).
  3. Send a new message — the LLM call fails with HTTP 400.
  4. Every subsequent message in the same session also fails.
Image

Expected vs Actual Behavior

Conversation truncation should never produce an orphaned tool_result block. If a truncation boundary falls inside a tool-call pair, the incomplete pair should be dropped.

Logs / Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions