feat: add provider tool call lifecycle events - #6973
Draft
TheCodingCvrlo wants to merge 1 commit into
Draft
Conversation
Surface provider-executed (server-side) tool calls (e.g. Mistral web search) as a session lifecycle, parallel to tool_execution_updated for locally-run tools: - llm.ProviderToolCall + a "provider_tool_call" event on the base LLM EventEmitter (same seam as metrics_collected) - AgentSession "provider_tool_execution_updated" event with ProviderToolCallStarted / ProviderToolCallEnded, bridged from the LLM event in AgentActivity - mistralai plugin emits it from ToolExecutionStarted/Done Gives an early "started" edge (to drive real-time UX such as a background sound while a server-side tool runs) plus an "ended" edge with the result, without touching ChatChunk. Relates to livekit#5869.
TheCodingCvrlo
marked this pull request as ready for review
August 26, 2026 13:08
TheCodingCvrlo
marked this pull request as draft
August 26, 2026 13:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracking issue: #6984
Summary
Surfaces provider-executed (server-side) tool calls — e.g. Mistral web search, and applicable to any provider with built-in tools — as a first-class lifecycle on
AgentSession, parallel totool_execution_updatedfor locally-executed tools.llm): newProviderToolCallpayload + aprovider_tool_callevent on the baseLLMEventEmitter (the same seam plugins already use formetrics_collected). No change toChatChunk.voice): newprovider_tool_execution_updatedsession event carrying a discriminatedProviderToolCallStarted | ProviderToolCallEnded.AgentActivitybridges the LLM event onto the session, wired right next tometrics_collected.mistralai): emitsprovider_tool_callby translating the Conversations stream'sToolExecutionStarted/ToolExecutionDone. No bespoke events on the LLM.Motivation
Context: Related discussion on #5869 with @tinalenguyen and @jeanprbt . #5869 adds a single terminal
function_tools_calledevent (once per turn). This PR gives a higher abstraction by adding the lifecycle needed to modify state while provider tools are executed, e.g. playing a "thinking"/background sound for exactly the duration of a web search.The design mirrors the existing local-tool lifecycle (
ToolCallStarted/ToolCallEndedviatool_execution_updated) so consumers get a consistent, provider-agnostic API and subscribe once.Design notes
ProviderToolCall) andemiton the LLM; the framework owns the app-facingprovider_tool_execution_updatedcontract and the bridge, so any future provider plugin gets the session event for free.ProviderToolCallEndedcarriesresult(the tool output) when the provider returns one.Tests
tests/test_plugin_mistralai_llm.py— the plugin's_parse_eventemitsprovider_tool_call(started → delta accumulates → done with full args + result; done-without-start is safe).tests/test_provider_tool_events.py— end-to-end through a realAgentSession:provider_tool_execution_updatedfires start→end per tool, in order.make checkclean locally (ruff + mypy strict).Open questions for maintainers
function_tools_calledas the per-turn summary and this as the lifecycle, or unify naming).remote_sessionprotobuf relay (which would need alivekit/protocolmessage) are natural follow-ups.resultshould be structured rather thanstr.Opening as a draft for discussion.