Skip to content

feat: add async_execute_tool_calls hook to CustomLogger#22864

Draft
mpcusack-altos wants to merge 1 commit intoBerriAI:mainfrom
mpcusack-altos:mcusack/tool-call-hook-framework
Draft

feat: add async_execute_tool_calls hook to CustomLogger#22864
mpcusack-altos wants to merge 1 commit intoBerriAI:mainfrom
mpcusack-altos:mcusack/tool-call-hook-framework

Conversation

@mpcusack-altos
Copy link
Contributor

Relevant issues

Replaces #20488 (part 1 of 2)

Summary

Adds a simplified tool execution hook pattern to the LiteLLM framework:

  • ToolCallResult NamedTuple in custom_logger.py for structured results
  • async_execute_tool_calls() method on CustomLogger base class
  • _call_tool_execution_hooks() in BaseLLMHTTPHandler that aggregates results from all callbacks, constructs follow-up messages (preserving thinking blocks), and makes the follow-up API request
  • _filter_handled_tool_calls() to allow multiple callbacks to handle different tool calls from the same response

This moves agentic loop orchestration into the HTTP handler so CustomLogger implementations only need to execute tool calls and return results.

Pre-Submission checklist

  • I have Added testing in the tests/test_litellm/ directory
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review

Test plan

  • Verify ToolCallResult import works: from litellm.integrations.custom_logger import ToolCallResult
  • Verify _call_tool_execution_hooks is called before legacy agentic hooks in BaseLLMHTTPHandler
  • Full test suite in part 2 PR (websearch handler refactor)

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Mar 5, 2026 5:09am

Request Review

Adds a simplified tool execution hook pattern to the LiteLLM framework:

- ToolCallResult NamedTuple in custom_logger.py for structured tool results
- async_execute_tool_calls() method on CustomLogger base class
- _call_tool_execution_hooks() in BaseLLMHTTPHandler that aggregates
  results from all callbacks, constructs follow-up messages (preserving
  thinking blocks), and makes the follow-up API request
- _filter_handled_tool_calls() to allow multiple callbacks to handle
  different tool calls from the same response

This is a framework-level change that moves agentic loop orchestration
into the HTTP handler, so individual CustomLogger implementations only
need to execute tool calls and return results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant