-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(ai): restore ToolLoopAgent onFinish callbacks #14336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-v6.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'ai': patch | ||
| --- | ||
|
|
||
| Fix `ToolLoopAgent` `onFinish` callbacks on the v6 release line so per-call `onFinish` is accepted again and merged with the constructor-level callback for `generate()` and `stream()`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,10 @@ import { StreamTextTransform } from '../generate-text/stream-text'; | |
| import { StreamTextResult } from '../generate-text/stream-text-result'; | ||
| import { ToolSet } from '../generate-text/tool-set'; | ||
| import { TimeoutConfiguration } from '../prompt/call-settings'; | ||
| import type { ToolLoopAgentOnStepFinishCallback } from './tool-loop-agent-settings'; | ||
| import type { | ||
| ToolLoopAgentOnFinishCallback, | ||
| ToolLoopAgentOnStepFinishCallback, | ||
| } from './tool-loop-agent-settings'; | ||
|
|
||
| /** | ||
| * Parameters for calling an agent. | ||
|
|
@@ -61,6 +64,11 @@ export type AgentCallParameters<CALL_OPTIONS, TOOLS extends ToolSet = {}> = ([ | |
| * Callback that is called when each step (LLM call) is finished, including intermediate steps. | ||
| */ | ||
| onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>; | ||
|
|
||
| /** | ||
| * Callback that is called when all steps are finished and the response is complete. | ||
| */ | ||
| onFinish?: ToolLoopAgentOnFinishCallback<TOOLS>; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Useful? React with 👍 / 👎. |
||
| }; | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
onFinishtoAgentCallParametersalso widensToolLoopAgentSettings.prepareCall(it is typed asOmit<AgentCallParameters, 'onStepFinish'>), butToolLoopAgent.generate()/stream()immediately destructureonFinishand callprepareCall(options)without it. This creates a type/runtime mismatch whereprepareCallappears able to read per-callonFinishbut will always see it as absent, which can silently break user code that branches on this callback. Please either omitonFinishfrom theprepareCallinput type as well or pass it through consistently.Useful? React with 👍 / 👎.