Skip to content

Each tool_use block must have a corresponding tool_result block in the next message #3504

Closed

Description

@hongliang-nemovideo

google/adk-python

Describe the bug
The detail error message like below:

litellm.exceptions.BadRequestError: litellm.BadRequestError: AnthropicException - {"type":"error","error":{"type":"invalid_request_error","message":"messages.4: tool_use ids were found without tool_result blocks immediately after: toolu_014qrA41Neqm6NHZTstHQfCm. Each tool_use block must have a corresponding tool_result block in the next message."},"request_id":"req_011CV3JFQ1toRhQLqcqR7KDE"}

To Reproduce

  1. Using cloude4.5 mounted by litellm, if there is no response from the tool call in the conversation, the above error will be reported.
  2. You can no longer continue the conversation in this session.

Activity

  1. added
    models[Component] This issue is related to model support
    on Nov 12, 2025
  2. added theissue type on Nov 12, 2025
  3. hongliang-nemovideo commented on Nov 12, 2025

    @hongliang-nemovideo
    Author

    I use the vertex session service to save the context.

  4. self-assigned this
    on Nov 12, 2025
  5. GWeale commented on Nov 12, 2025

    @GWeale
    Collaborator

    ADK emits the tool_result immediately after every tool_use, so Claude only raises that error when the stored transcript drops the function_response. Can you look more into the Vertex session history you’re replaying and ensure each tool_use event is followed by its matching tool_result (even if empty).

  6. hongliang-nemovideo commented on Nov 12, 2025

    @hongliang-nemovideo
    Author

    yes,there is no a matching tool_result in the sessin history. But I can't understand the session can't continue any more...

  7. hongliang-nemovideo commented on Nov 12, 2025

    @hongliang-nemovideo
    Author

    now, I start to find result in the liteLlm module.

  8. GWeale commented on Nov 12, 2025

    @GWeale
    Collaborator

    If the persisted history is missing the tool_result, Claude will refuse to continue, there’s no way for ADK to recover that turn. Please make sure whatever is saving to Vertex/LiteLLM always stores the function_response event ADK emits right after each tool finishes; otherwise you must either backfill the missing tool_result or start a new session.

  9. hongliang-nemovideo commented on Nov 12, 2025

    @hongliang-nemovideo
    Author

    I found a close issue in liteLlm resp
    BerriAI/litellm#12404
    I'm trying...

  10. hongliang-nemovideo commented on Nov 12, 2025

    @hongliang-nemovideo
    Author

    not work...

  11. self-assigned this
    on Nov 15, 2025
  12. GWeale commented on Nov 17, 2025

    @GWeale
    Collaborator

    Hi @hongliang-nemovideo Thank you for pointing this out, we just put a fix in for this. If it is not working after the next release please reopen!

  13. added a commit that references this issue on Nov 17, 2025
    0ec0195
  14. added a commit that references this issue on Nov 27, 2025
    f7971d7
  15. added a commit that references this issue on Aug 11, 2026
    9a7f8a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

models[Component] This issue is related to model support

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions