You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**`strategy`**: The caching strategy to use (`"read"`, `"write"`, `"both"`, or `"no"`).
37
+
-**`strategy`**: The caching strategy to use (`"execute"`, `"record"`, `"both"`, or `None`).
38
38
-**`cache_dir`**: Directory where cache files are stored. Defaults to `".cache"`.
39
-
-**`filename`**: Name of the cache file to write to or read from. If not specified in write mode, a timestamped filename will be generated automatically (format: `cached_trajectory_YYYYMMDDHHMMSSffffff.json`).
39
+
-**`filename`**: Name of the cache file to write to or read from. If not specified in record mode, a timestamped filename will be generated automatically (format: `cached_trajectory_YYYYMMDDHHMMSSffffff.json`).
40
40
-**`execute_cached_trajectory_tool_settings`**: Configuration for the trajectory execution tool (optional). See [Execution Settings](#execution-settings) below.
41
41
42
42
### Execution Settings
@@ -61,7 +61,7 @@ You can adjust this value based on your application's responsiveness:
61
61
62
62
## Usage Examples
63
63
64
-
### Writing a Cache (Recording)
64
+
### Recording a Cache
65
65
66
66
Record agent actions to a cache file for later replay:
67
67
@@ -73,7 +73,7 @@ with ComputerAgent() as agent:
73
73
agent.act(
74
74
goal="Fill out the login form with username 'admin' and password 'secret123'",
75
75
caching_settings=CachingSettings(
76
-
strategy="write", # you could also use "both" here
76
+
strategy="record", # you could also use "both" here
77
77
cache_dir=".cache",
78
78
filename="login_test.json"
79
79
)
@@ -82,7 +82,7 @@ with ComputerAgent() as agent:
82
82
83
83
After execution, a cache file will be created at `.cache/login_test.json` containing all the tool use actions performed by the agent.
84
84
85
-
### Reading from Cache (Replaying)
85
+
### Executing from Cache (Replaying)
86
86
87
87
Provide the agent with access to previously recorded trajectories:
88
88
@@ -94,13 +94,13 @@ with ComputerAgent() as agent:
94
94
agent.act(
95
95
goal="Fill out the login form",
96
96
caching_settings=CachingSettings(
97
-
strategy="read", # you could also use "both" here
97
+
strategy="execute", # you could also use "both" here
98
98
cache_dir=".cache"
99
99
)
100
100
)
101
101
```
102
102
103
-
When using `strategy="read"`, the agent receives two additional tools:
103
+
When using `strategy="execute"`, the agent receives two additional tools:
104
104
105
105
1.**`retrieve_available_trajectories_tool`**: Lists all available cache files in the cache directory
106
106
2.**`execute_cached_executions_tool`**: Executes a specific cached trajectory
@@ -109,7 +109,7 @@ The agent will automatically check if a relevant cached trajectory exists and us
109
109
110
110
### Referencing Cache Files in Goal Prompts
111
111
112
-
When using `strategy="read"` or `strategy="both"`, **you need to inform the agent about which cache files are available and when to use them**. This is done by including cache file information directly in your goal prompt.
112
+
When using `strategy="execute"` or `strategy="both"`, **you need to inform the agent about which cache files are available and when to use them**. This is done by including cache file information directly in your goal prompt.
113
113
114
114
#### Explicit Cache File References
115
115
@@ -126,7 +126,7 @@ with ComputerAgent() as agent:
126
126
If the cache file "open_website_in_chrome.json" is available, please use it
127
127
for this execution. It will open a new window in Chrome and navigate to the website.""",
128
128
caching_settings=CachingSettings(
129
-
strategy="read",
129
+
strategy="execute",
130
130
cache_dir=".cache"
131
131
)
132
132
)
@@ -149,7 +149,7 @@ with ComputerAgent() as agent:
149
149
Check if a cache file named "{test_id}.json" exists. If it does, use it to
150
150
replay the test actions, then verify the results.""",
151
151
caching_settings=CachingSettings(
152
-
strategy="read",
152
+
strategy="execute",
153
153
cache_dir="test_cache"
154
154
)
155
155
)
@@ -171,7 +171,7 @@ with ComputerAgent() as agent:
171
171
Choose the most recent one if multiple are available, as it likely contains
172
172
the most up-to-date interaction sequence.""",
173
173
caching_settings=CachingSettings(
174
-
strategy="read",
174
+
strategy="execute",
175
175
cache_dir=".cache"
176
176
)
177
177
)
@@ -195,7 +195,7 @@ with ComputerAgent() as agent:
195
195
196
196
After each cached execution, verify the step completed successfully before proceeding.""",
197
197
caching_settings=CachingSettings(
198
-
strategy="read",
198
+
strategy="execute",
199
199
cache_dir=".cache"
200
200
)
201
201
)
@@ -219,7 +219,7 @@ with ComputerAgent() as agent:
delay_time_between_actions=1.0# Wait 1 second between each action
@@ -323,7 +323,7 @@ The delay between actions can be customized using `CachedExecutionToolSettings`
323
323
## Limitations
324
324
325
325
-**UI State Sensitivity**: Cached trajectories assume the UI is in the same state as when they were recorded. If the UI has changed, the replay may fail or produce incorrect results.
326
-
-**No on_message Callback**: When using `strategy="write"` or `strategy="both"`, you cannot provide a custom `on_message` callback, as the caching system uses this callback to record actions.
326
+
-**No on_message Callback**: When using `strategy="record"` or `strategy="both"`, you cannot provide a custom `on_message` callback, as the caching system uses this callback to record actions.
327
327
-**Verification Required**: After executing a cached trajectory, the agent should verify that the results are correct, as UI changes may cause partial failures.
328
328
329
329
## Example: Complete Test Workflow
@@ -340,7 +340,7 @@ with ComputerAgent() as agent:
340
340
agent.act(
341
341
goal="Navigate to the login page and log in with username 'testuser' and password 'testpass123'",
342
342
caching_settings=CachingSettings(
343
-
strategy="write",
343
+
strategy="record",
344
344
cache_dir="test_cache",
345
345
filename="user_login.json"
346
346
)
@@ -356,7 +356,7 @@ with ComputerAgent() as agent:
356
356
the login sequence. It contains the steps to navigate to the login page and
0 commit comments