Skip to content

Commit 5a0cbef

Browse files
authored
add open vs. loop use case diff
1 parent cb8d807 commit 5a0cbef

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,30 @@ const result = await session.prompt("What is the weather in Seattle?");
256256
257257
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.
258258
259+
#### Do I need auto execution?
260+
261+
In general, automatic execution is suitable for use cases where the model quality is good enough via prompt tuning. That can either mean you are tolerable for certain mistakes that the model makes when making tool calls, or the task is simple enough for the model to handle (e.g, just a few distinct tools, short and clean tool output, short context window, etc)
262+
263+
On the other hand, open loop allows more flexibility for intercepting at various points in the planner loop (the reason->action->observation loop) where you can inject your business logic programmatically.
264+
265+
Here are a few patterns where open loop would be useful:
266+
267+
1) context management
268+
269+
If your session might go through a long chain of contents, and the previous tool results are no longer important or relevant for your use case, open loop gives the flexibility of editing and recreating the session in the middle of a tool call. You can manually compress and modify the history, and recreate a new session with less content.
270+
271+
For example, for a shopping agent, your tool keeps track of a live shopping cart, but only the latest cart status is important. When there have been multiple rounds of cart updates, you might need to compress the tool call history to avoid exceeding context window, improve latency and quality.
272+
273+
2) Conditional loop breaking
274+
275+
If your business logic requires some determinism in some critical states, open loop allows the flexibility to early exit the planner loop and output a pre-determined action.
276+
277+
For example, for a shopping agent, you might be required to get an explicit confirmation before placing the order. Whenever the tool `"place_order"` is called in the first time, you want to exit the planner loop immediately, and display a verbatim message to the user
278+
279+
3) Conditional constraints
280+
281+
282+
259283
#### Concurrent tool use
260284
261285
Developers should be aware that the model might call their tool multiple times, concurrently. For example, code such as

0 commit comments

Comments
 (0)