Skip to content

Commit 5f70b44

Browse files
committed
Explain multiple concurrent tool calls
1 parent 8f43009 commit 5f70b44

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ const result = await session.prompt("What is the weather in Seattle?");
179179

180180
In this example, the `tools` array defines a `getWeather` tool, specifying its name, description, input schema, and `execute` implementation. When the language model determines that a tool call is needed, the user agent invokes the `getWeather` tool's `execute()` function with the provided arguments and returns the result to the model, which can then incorporate it into its response.
181181

182+
#### Concurrent tool use
183+
184+
Developers should be aware that the model might call their tool multiple times, concurrently. For example, code such as
185+
186+
```js
187+
const result = await session.prompt("Which of these locations currently has the highest temperature? Seattle, Tokyo, Berlin");
188+
```
189+
190+
might call the above `"getWeather"` tool's `execute()` function three times. The model would wait for all tool call results to return, using the equivalent of `Promise.all()` internally, before it composes its final response.
191+
192+
Similarly, the model might call multiple different tools, if it believes they all are relevant when responding to the given prompt.
193+
182194
### Multimodal inputs
183195

184196
All of the above examples have been of text prompts. Some language models also support other inputs. Our design initially includes the potential to support images and audio clips as inputs. This is done by using objects in the form `{ type: "image", content }` and `{ type: "audio", content }` instead of strings. The `content` values can be the following:

0 commit comments

Comments
 (0)