Skip to content

Fallback to full trajectory condensation on malformed message errors #1529

@neubig

Description

@neubig

Summary

When we encounter a malformed message error from the language model, we should fall back to condensing the entire trajectory into a single message, similarly to how Claude Code does it.

Background

This approach was discussed as a way to handle edge cases in condensation. Currently, when we hit malformed message errors, we don't have a robust fallback mechanism. Claude Code's approach of condensing everything into a single message could help avoid some of the edge cases we've been trying to fix (e.g., mixture of thinking blocks, wrong order of action-observation event pairs).

Proposed Solution

Implement a fallback mechanism that:

  1. Detects malformed message errors from the language model
  2. Falls back to condensing the entire trajectory into a single comprehensive message (similar to Claude Code's approach)
  3. Keeps the existing condensation approach as the default, using this only as a fallback

Additional Context

  • This should be a fallback strategy, not the default behavior
  • We want to keep the option to not condense everything from scratch, as starting from scratch has a fairly high likelihood of confusing the agent (especially with open-source models)
  • The existing condensation approach should remain the primary method, with this as a safety net for error cases

Related Discussion

See: #1518 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority:mediumFor bugs, a serious source of annoyance, but not blocking a large number of users.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions