- Notifications
You must be signed in to change notification settings - Fork87
tool use without auto execution#162
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Added detailed explanations for tool use modes, including examples for open loop and closed loop execution.
Updated README to clarify tool-call and tool-result usage.
Added new types and enums for tool calls and responses.
jingyun19 commentedNov 19, 2025
tomayac left a comment
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.
Tried to make the code samples more readable and correct. Maybe consider running them all through a tool likeprettier, which catches typos like missing commas or parentheses.
As general feedback, could the explainer outline why developers would choose closed vs. open?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| awaitsession.append([ | ||
| {role:"user", content:"What is the weather in Seattle?"}, | ||
| {role:"tool-call", content: {type:"tool-call", value: {callID:" get_weather_1", name:"get_weather", arguments: {location:"Seattle"}}}, | ||
| {role:"tool-result", content: {type:"tool-response", value: {callID:"get_weather_1", name:"get_weather", result: [{type:"object", value: {temperature:"55F", humidity:"67%"}}]}}, | ||
| {role:"assistant", content:"The temperature in Seattle is 55F and humidity is 67%"}, | ||
| ]); |
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.
| await session.append([ | |
| {role: "user", content: "What is the weather in Seattle?"}, | |
| {role: "tool-call", content: {type: "tool-call", value: {callID:" get_weather_1", name: "get_weather", arguments: {location:"Seattle"}}}, | |
| {role: "tool-result", content: {type: "tool-response", value: {callID: "get_weather_1", name: "get_weather", result: [{type:"object", value: {temperature: "55F", humidity: "67%"}}]}}, | |
| {role: "assistant", content: "The temperature in Seattle is 55F and humidity is 67%"}, | |
| ]); | |
| await session.append([ | |
| { role: "user", content: "What is the weather in Seattle?" }, | |
| { | |
| role: "tool-call", | |
| content: { | |
| type: "tool-call", | |
| value: { | |
| callID: " get_weather_1", | |
| name: "get_weather", | |
| arguments: { location: "Seattle" }, | |
| }, | |
| }, | |
| }, | |
| { | |
| role: "tool-result", | |
| content: { | |
| type: "tool-response", | |
| value: { | |
| callID: "get_weather_1", | |
| name: "get_weather", | |
| result: [ | |
| { type: "object", value: { temperature: "55F", humidity: "67%" } }, | |
| ], | |
| }, | |
| }, | |
| }, | |
| { | |
| role: "assistant", | |
| content: "The temperature in Seattle is 55F and humidity is 67%", | |
| }, | |
| ]); |
| ]); | ||
| ``` | ||
| Note that "role" and "type" now supports "tool-call" and "tool-result". |
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.
| Note that "role" and "type" nowsupports"tool-call" and "tool-result". | |
| Note that`"role"` and`"type"` nowsupport`"tool-call"` and`"tool-result"`. |
| sessionOptions=structuredClone(options); | ||
| sessionOptions.expectedOutputs.push(["tool-call"]); | ||
| session=awaitLanguageModel.create(sessionOptions); | ||
| var result=awaitsession.prompt("What is the weather in Seattle?"); | ||
| if (result.type=="tool-call") { | ||
| if (result.name=="get_weather") { | ||
| consttool_result=getWeather(result.arguments.location); | ||
| result=session.prompt([{role:"tool-result", content: {type:"tool-result", value: {callId:result.callID, name:result.name, result: [{type:"object", value: tool_result}]}}}]) | ||
| } | ||
| }else{ | ||
| console.log(result) | ||
| } |
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.
| sessionOptions = structuredClone(options); | |
| sessionOptions.expectedOutputs.push(["tool-call"]); | |
| session = await LanguageModel.create(sessionOptions); | |
| var result = await session.prompt("What is the weather in Seattle?"); | |
| if (result.type=="tool-call") { | |
| if (result.name == "get_weather") { | |
| const tool_result = getWeather(result.arguments.location); | |
| result = session.prompt([{role:"tool-result", content: {type: "tool-result", value: {callId: result.callID, name: result.name, result: [{type:"object", value: tool_result}]}}}]) | |
| } | |
| } else{ | |
| console.log(result) | |
| } | |
| sessionOptions = structuredClone(options); | |
| sessionOptions.expectedOutputs.push(["tool-call"]); | |
| session = await LanguageModel.create(sessionOptions); | |
| var result = await session.prompt("What is the weather in Seattle?"); | |
| if (result.type == "tool-call") { | |
| if (result.name == "get_weather") { | |
| const tool_result = getWeather(result.arguments.location); | |
| result = session.prompt([ | |
| { | |
| role: "tool-result", | |
| content: { | |
| type: "tool-result", | |
| value: { | |
| callId: result.callID, | |
| name: result.name, | |
| result: [{ type: "object", value: tool_result }], | |
| }, | |
| }, | |
| }, | |
| ]); | |
| } | |
| } else { | |
| console.log(result); | |
| } |
| #### Closed Loop: | ||
| To enable automatic execution, add a`execute` function for each tool's implementation, and add a`toolUseConfig` to indicate that execution is enabled and pose a max number of tool calls invoked in a single session generation: |
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.
| To enable automatic execution, adda`execute` function for each tool's implementation, and add a`toolUseConfig` to indicate that execution is enabled and pose a max number of tool calls invoked in a single session generation: | |
| To enable automatic execution, addan`execute` function for each tool's implementation, and add a`toolUseConfig` to indicate that execution is enabled and pose a max number of tool calls invoked in a single session generation: |
| sessionOptions.expectedOutputs.push(["tool-call"]); | ||
| session=awaitLanguageModel.create(sessionOptions); | ||
| var result=awaitsession.prompt("What is the weather in Seattle?"); |
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.
| var result = await session.prompt("What is the weather in Seattle?"); | |
| let result = await session.prompt("What is the weather in Seattle?"); |
| Example: | ||
| ```js | ||
| sessionOptions=structuredClone(options); |
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.
| sessionOptions = structuredClone(options); | |
| constsessionOptions = structuredClone(options); |
| ```js | ||
| sessionOptions=structuredClone(options); | ||
| sessionOptions.expectedOutputs.push(["tool-call"]); | ||
| session=awaitLanguageModel.create(sessionOptions); |
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.
| session = await LanguageModel.create(sessionOptions); | |
| constsession = await LanguageModel.create(sessionOptions); |
Co-authored-by: Thomas Steiner <tomac@google.com>
Co-authored-by: Thomas Steiner <tomac@google.com>
Added explanation about automatic execution and constraints in planner loop.
jingyun19 commentedDec 1, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I added a new section to describe use cases where open loop is preferred. cc@tomayac |
reillyeon commentedDec 11, 2025
I hadn't previously considered the context compression use case. That's interesting and motivating to enable developers to manipulate the conversation at this low level. |
Uh oh!
There was an error while loading.Please reload this page.
Update explainer and spec to support tool use functionalities without automatic execution.
Explainer: added an example and explained how to make tool calls
Spec: reflect IDL changes inhttps://chromium-review.googlesource.com/c/chromium/src/+/7092943
Preview |Diff