feat(ai): add experimental_onLanguageModelCallStart/End to AgentCallParameters#15034
Open
Mmartinrusso wants to merge 1 commit intovercel:mainfrom
Open
feat(ai): add experimental_onLanguageModelCallStart/End to AgentCallParameters#15034Mmartinrusso wants to merge 1 commit intovercel:mainfrom
Mmartinrusso wants to merge 1 commit intovercel:mainfrom
Conversation
…arameters Add `experimental_onLanguageModelCallStart` and `experimental_onLanguageModelCallEnd` to `AgentCallParameters`, `AgentStreamParameters`, and `ToolLoopAgentSettings`. These callbacks already exist in `generateText`/`streamText` and work at runtime via the `...options` spread but TypeScript rejects them because they are absent from `AgentCallParameters`. This change makes the type surface match the runtime behavior and enables proper observability of per-LLM-call events in agent loops. Closes vercel#14278 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Background
generateTextandstreamTextsupportexperimental_onLanguageModelCallStart/Endfor per-LLM-call observability (latency, logging). These callbacks worked at runtime throughToolLoopAgentbecause unrecognised fields in...optionsflow throughprepareCallinto the underlying call. However,AgentCallParametersdid not declare them, forcing users to useas any.Summary
experimental_onLanguageModelCallStartandexperimental_onLanguageModelCallEndtoAgentCallParametersandAgentStreamParametersToolLoopAgentSettingsso they can be set once at construction timeToolLoopAgent.generate()andToolLoopAgent.stream(), merging settings-level and call-level callbacks (same pattern asexperimental_onToolExecutionStart/End)tool-loop-agent.test-d.tsManual Verification
pnpm tsc --noEmitpasses inpackages/aipnpm vitest run src/agent/— 91/91 passAgentCallParametersandToolLoopAgentSettingswith the correct typesChecklist
Related Issues
Fixes #14278