Skip to content
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

Add singleToolPerStep option to prevent multiple tool calls within one step #3854

Open
RostyslavManko opened this issue Nov 23, 2024 · 1 comment
Labels
ai/core enhancement New feature or request

Comments

@RostyslavManko
Copy link

Feature Description

I propose adding a new configuration option singleToolPerStep that would restrict the AI to generating only one tool call per step. Currently, the AI SDK allows multiple tool calls to be generated within a single step, which can lead to race conditions and complex execution flows.

This would be implemented at the SDK level rather than requiring developers to implement their own synchronization logic. When enabled, the SDK would:

  1. Modify the prompt/system message to instruct the AI to only generate one tool call per step
  2. Enforce this restriction at the protocol level by only accepting the first tool call in a step
  3. Automatically continue to the next step after a tool call is completed

Use Cases

Use Cases

  1. Terminal/Command Execution: When executing terminal commands, it's crucial to process them sequentially and analyze each output before proceeding with the next command.

  2. Database Operations: When performing database queries or updates, executing one operation at a time ensures proper transaction handling and prevents race conditions.

  3. API Calls: When making external API calls, processing one request at a time allows for proper error handling and response analysis before proceeding.

  4. File System Operations: When working with files, sequential operations ensure proper file handling and prevent concurrent access issues.

Additional context

No response

@RostyslavManko RostyslavManko added the enhancement New feature or request label Nov 23, 2024
@grabbou
Copy link

grabbou commented Nov 24, 2024

I have recently built an agent that executes terminal commands, and I actually appreciate this tool can run certain commands in parallel. I design each tool so that it can run independently. If it can't, I explicitly configure it via its description and/or input parameters, and generally, that works just fine!

I don't have anything per se against adding such configuration option, however, I would like to emphasize that current parallel behavior is actually working quite awesome of me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants