Skip to content

Commit f8b416a

Browse files
chore: change name of caching strategy both to auto
1 parent 6d17375 commit f8b416a

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

docs/06_caching.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The caching mechanism supports three strategies, configured via the `caching_set
1313
- **`None`** (default): No caching is used. The agent executes normally without recording or replaying actions.
1414
- **`"record"`**: Records all agent actions to a cache file for future replay.
1515
- **`"execute"`**: Provides tools to the agent to list and execute previously cached trajectories.
16-
- **`"both"`**: Combines execute and record modes - the agent can use existing cached trajectories and will also record new ones.
16+
- **`"auto"`**: Combines execute and record modes - the agent can use existing cached trajectories and will also record new ones.
1717

1818
## Configuration
1919

@@ -23,7 +23,7 @@ Caching is configured using the `CachingSettings` class:
2323
from askui.models.shared.settings import CachingSettings, CachedExecutionToolSettings
2424

2525
caching_settings = CachingSettings(
26-
strategy="record", # One of: "execute", "record", "both", or None
26+
strategy="record", # One of: "execute", "record", "auto", or None
2727
cache_dir=".cache", # Directory to store cache files
2828
filename="my_test.json", # Filename for the cache file (optional for record mode)
2929
execute_cached_trajectory_tool_settings=CachedExecutionToolSettings(
@@ -34,7 +34,7 @@ caching_settings = CachingSettings(
3434

3535
### Parameters
3636

37-
- **`strategy`**: The caching strategy to use (`"execute"`, `"record"`, `"both"`, or `None`).
37+
- **`strategy`**: The caching strategy to use (`"execute"`, `"record"`, `"auto"`, or `None`).
3838
- **`cache_dir`**: Directory where cache files are stored. Defaults to `".cache"`.
3939
- **`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`).
4040
- **`execute_cached_trajectory_tool_settings`**: Configuration for the trajectory execution tool (optional). See [Execution Settings](#execution-settings) below.
@@ -73,7 +73,7 @@ with ComputerAgent() as agent:
7373
agent.act(
7474
goal="Fill out the login form with username 'admin' and password 'secret123'",
7575
caching_settings=CachingSettings(
76-
strategy="record", # you could also use "both" here
76+
strategy="record", # you could also use "auto" here
7777
cache_dir=".cache",
7878
filename="login_test.json"
7979
)
@@ -94,7 +94,7 @@ with ComputerAgent() as agent:
9494
agent.act(
9595
goal="Fill out the login form",
9696
caching_settings=CachingSettings(
97-
strategy="execute", # you could also use "both" here
97+
strategy="execute", # you could also use "auto" here
9898
cache_dir=".cache"
9999
)
100100
)
@@ -109,7 +109,7 @@ The agent will automatically check if a relevant cached trajectory exists and us
109109

110110
### Referencing Cache Files in Goal Prompts
111111

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.
112+
When using `strategy="execute"` or `strategy="auto"`, **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.
113113

114114
#### Explicit Cache File References
115115

@@ -233,7 +233,7 @@ This is particularly useful when:
233233
- UI elements take time to become interactive after appearing
234234
- You're testing on slower hardware or environments
235235

236-
### Using Both Strategies
236+
### Using Auto Strategy
237237

238238
Enable both reading and writing simultaneously:
239239

@@ -245,7 +245,7 @@ with ComputerAgent() as agent:
245245
agent.act(
246246
goal="Complete the checkout process",
247247
caching_settings=CachingSettings(
248-
strategy="both",
248+
strategy="auto",
249249
cache_dir=".cache",
250250
filename="checkout_test.json"
251251
)
@@ -323,7 +323,7 @@ The delay between actions can be customized using `CachedExecutionToolSettings`
323323
## Limitations
324324

325325
- **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="record"` 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="auto"`, you cannot provide a custom `on_message` callback, as the caching system uses this callback to record actions.
327327
- **Verification Required**: After executing a cached trajectory, the agent should verify that the results are correct, as UI changes may cause partial failures.
328328

329329
## Example: Complete Test Workflow

src/askui/agent_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def act(
142142
for the act execution. Controls recording and replaying of action
143143
sequences (trajectories). Available strategies: None (default, no
144144
caching), "record" (record actions to cache file), "execute" (replay
145-
from cached trajectories), "both" (execute and record). Defaults to
145+
from cached trajectories), "auto" (execute and record). Defaults to
146146
no caching.
147147
148148
Returns:
@@ -208,7 +208,7 @@ def act(
208208
agent.act(
209209
goal="Complete the checkout process",
210210
caching_settings=CachingSettings(
211-
strategy="both",
211+
strategy="auto",
212212
cache_dir=".cache",
213213
filename="checkout.json"
214214
)
@@ -281,7 +281,7 @@ def _patch_act_with_cache(
281281
cache_manager: CacheManager | None = None
282282

283283
# Setup execute mode: add caching tools and modify system prompt
284-
if caching_settings.strategy in ["execute", "both"]:
284+
if caching_settings.strategy in ["execute", "auto"]:
285285
# Create CacheExecutor with execution settings and add to speakers
286286
cache_executor = CacheExecutor(caching_settings.execution_settings)
287287
self._conversation.speakers.add_speaker(cache_executor)
@@ -308,7 +308,7 @@ def _patch_act_with_cache(
308308
tools = caching_tools
309309

310310
# Setup record mode: create cache manager for recording
311-
if caching_settings.strategy in ["record", "both"]:
311+
if caching_settings.strategy in ["record", "auto"]:
312312
cache_writer_settings = (
313313
caching_settings.writing_settings or CacheWritingSettings()
314314
)

src/askui/models/shared/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Resolution(NamedTuple):
3434
DEFAULT_LOCATE_RESOLUTION = Resolution(1280, 800)
3535
DEFAULT_GET_RESOLUTION = Resolution(1280, 800)
3636

37-
CACHING_STRATEGY = Literal["execute", "record", "both"]
37+
CACHING_STRATEGY = Literal["execute", "record", "auto"]
3838
CACHE_PARAMETER_IDENTIFICATION_STRATEGY = Literal["llm", "preset"]
3939
CACHING_VISUAL_VERIFICATION_METHOD = Literal["phash", "ahash", "none"]
4040

@@ -269,11 +269,11 @@ class CachingSettings(BaseModel):
269269
- None: Caching disabled (default)
270270
- "execute": Replay actions from cache
271271
- "record": Record actions to cache
272-
- "both": Execute from cache if available, otherwise record
272+
- "auto": Execute from cache if available, otherwise record
273273
cache_dir (str): Directory path for storing cache files.
274274
Default: ".askui_cache".
275-
writing_settings: Settings for cache recording (used in "record"/"both" modes)
276-
execution_settings: Settings for cache playback (used in "execute"/"both" modes)
275+
writing_settings: Settings for cache recording (used in "record"/"auto" modes)
276+
execution_settings: Settings for cache playback (used in "execute"/"auto" modes)
277277
"""
278278

279279
strategy: CACHING_STRATEGY | None = None

tests/e2e/agent/test_act_caching.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_act_with_caching_strategy_both(vision_agent: ComputerAgent) -> None:
6262
vision_agent.act(
6363
goal="Tell me a joke",
6464
caching_settings=CachingSettings(
65-
strategy="both",
65+
strategy="auto",
6666
cache_dir=str(cache_dir),
6767
filename=cache_filename,
6868
),

0 commit comments

Comments
 (0)