feat: add support to Anthropic's context editing feature

What does this merge request do and why?

This change adds a new "context management" feature to the workflow system that helps control memory usage when AI agents process long conversations or use many tools.

The configuration is flexible - developers can specify what triggers the cleanup (token count or number of tool uses), how much to keep, minimum amounts to clear, which tools to exclude from cleanup, and whether to clear tool input data. Multiple cleanup rules can be defined for different scenarios.

The changes include the data models to define these rules, integration into the existing flow configuration system, a helper method to access the settings, and comprehensive tests covering various scenarios including edge cases and validation. The feature is optional - if not configured, the system behaves as before.

This is implemented identically in both the experimental and v1 versions of the platform to maintain consistency across different API versions.

What is Anthropic's context editing feature:

Context editing allows you to automatically manage conversation context as it grows, helping you optimize costs and stay within context window limits.

The clear_tool_uses_20250919 strategy,  When activated, the API automatically clears the oldest tool results in chronological order, replacing them with placeholder text to let Claude know the tool result was removed.

More information here: https://platform.claude.com/docs/en/build-with-claude/context-editing

Issue:

closes #1543

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.
  • If this change requires executor implementation: verified that issues/MRs exist for both Go executor and Node executor or confirmed that changes are backward-compatible and don't break existing executor functionality.
Edited by Joey Khabie

Merge request reports

Loading