Add stopAfterToolCalls option for OpenAI-compatible workflows#108
Closed
ajason wants to merge 3 commits intomattt:mainfrom
Closed
Add stopAfterToolCalls option for OpenAI-compatible workflows#108ajason wants to merge 3 commits intomattt:mainfrom
ajason wants to merge 3 commits intomattt:mainfrom
Conversation
Owner
|
Hi @ajason. Thanks for opening this PR! I totally agree that the current approach to tool calling is insufficient. As far as solutions, I think I just opened #109, which follows that approach, implementing a delegate pattern with hooks for observing generation and execution of tool calls, and controlling whether to allow execution (with option to provide result programmatically). Please take a look at that and let me know if you have any concerns about that satisfying your use case. |
Contributor
Author
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.
stopAfterToolCallstoggle inOpenAILanguageModel.CustomGenerationOptions.Motivation
In production environments, tool execution is often managed by an "external orchestrator" (e.g., dispatching calls to independent workers, invoking internal services, or implementing permission and auditing logic). The current default behavior automatically executes tools immediately after the model generates tool calls. This is unsuitable for systems that require:
The
stopAfterToolCallsflag allows the client to receive the tool calls without triggering automatic execution, handing control over the execution timing to the upper-level orchestrator.Use Cases / Scenarios
Behavior
stopAfterToolCalls == trueand the model generates tool calls: the generation process halts, returning the tool calls to the caller without execution.Testing
swift test --filter OpenAICustomOptionsTests