Skip to content

[Bug] Anthropic Provider block/removes key tool events for code execution and files #7171

@adiberk

Description

@adiberk

Description

Agno drops server_tool_use and *_tool_result blocks from message history.

When Claude uses code execution skills, the API response contains block types that
agno's format_messages() silently discards when building subsequent requests:
- server_tool_use (code execution tool call initiated by the server)
- bash_code_execution_tool_result
- text_editor_code_execution_tool_result

Without these blocks in the message history, Claude has no memory of having run code.
It therefore believes the file was never created and enters an infinite loop calling
get_generated_file, re-running code execution, and creating new file versions.

Steps to Reproduce

  1. Build an integration that lets you use files and contains with claude skills
  2. Ask claude to create a file
  3. have it call a tool after creating a file
  4. Claude after the tool call, will have no record that it created any file (bc we strip these events from history)

Agent Configuration (if applicable)

Just use claude and enable the correct code execution and maybe pdf skill

Expected Behavior

We need to include this missed events to ensure claude functions properly

Actual Behavior

We remove them

Screenshots or Logs (if applicable)

No response

Environment

- MacOS
- Agno  2.5.10/11

Possible Solutions (optional)

No response

Additional Context

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