-
Notifications
You must be signed in to change notification settings - Fork 62
Migrate act() to conversation-based architecture with Speaker pattern and add caching v2 features. #236
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Migrate act() to conversation-based architecture with Speaker pattern and add caching v2 features. #236
Changes from 39 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
7f2770c
refactor: migrate act to conversation-based architecture and update c…
philipph-askui d79a5cd
feat: add caching_v2 features and fix otel dependency for tracing
philipph-askui 835860a
feat: change default of `is_cacheable` flag to False
philipph-askui 08a1a0e
fix: update prompts to state of caching_v02
philipph-askui ec8e82b
fix: format, typechecking, liniting issues
philipph-askui 16983b4
fix: sanitizes messages before sending to API as we need to remove pr…
philipph-askui d6932f2
removes old 'llm_provider` field in CacheWritingSettings
philipph-askui 297b5e3
fix: add default cache directory (.askui_cache) to gitignore
philipph-askui cc47181
chore: change logging outputs to INFO
philipph-askui 6e3a52f
fix: removes old cache_writer and makes code use the new cache_manager
philipph-askui 57b887d
fix: handles problems due to tools now having uuid suffixes
philipph-askui 35d6149
fix: adds missing cache parameter handling
philipph-askui 6f08bce
fix: update outdated tests
philipph-askui 76daa92
feat: add method to truncate content for html reports to prevent floo…
philipph-askui 16257dd
fix: migrate caching to conversation-based architecture and add missi…
philipph-askui a4c6449
fix: bug in visual validation during cached execution
philipph-askui ac2caf1
chore: change default value for `visual_validation_threshold` to 10
philipph-askui 586aee3
fix: add explicit conversion to int of mouse move coordinats, as the …
philipph-askui aa93ff7
chore: change log message from warning to info
philipph-askui f04f1c9
fix: remove unnecessary files
philipph-askui 908d55d
fix: duplicate clipping of coordinates
philipph-askui 7f4b95f
fix: multiple bugs and code quality issues
philipph-askui 0b9e13b
fix: change default value of `delay_time_between_actions` from 0.5 to…
philipph-askui b60d1bf
feat: add usage statistics of caching to html reporter
philipph-askui f99082f
fix: bug where cached executions were reported as success when they w…
philipph-askui fdece1d
fix: change name of caching strategies to match new pattern from cach…
philipph-askui 6d961f8
fix: coding quality issue
philipph-askui 1c266ae
chore: add pydantic model for VisualValidationMetadata
philipph-askui ee78cbf
chore: move conversation to models/shared
philipph-askui 4029647
chore: refactor control loop and delete legacy code (custom_agent and…
philipph-askui d135838
feat: add callback system comparable to pytorch lightning
philipph-askui dfc9068
fix: bug in html report that led to a crash for non-cached executions
philipph-askui 19ab09c
feat: add new speaker handoff pattern that is more scalable and gener…
philipph-askui 9e3672b
feat: add conversation_id to conversation
philipph-askui 908b5ce
feat: add on_speaker_switch callback
philipph-askui 1650ff7
chore: resolve joint callback method into methods that handle them in…
philipph-askui 6d17375
chore: refactor usage tracking to integrate via callback
philipph-askui f8b416a
chore: change name of caching strategy `both` to `auto`
philipph-askui 33c72bf
Merge branch 'main' into chore/act_conversation_with_caching
philipph-askui 0b1d45e
fix: add missing `_on_speaker_switch` callback to docs
philipph-askui efe0624
Merge branch 'chore/act_conversation_with_caching' of https://github.…
philipph-askui f3ca227
fix: make tracing span names consistent with function names
philipph-askui 7d63869
chore: rename `handle_result_status` to `_handle_continue_conversation`
philipph-askui 56d3793
chore: move speaker switch into a dedicated function `switch_speaker_…
philipph-askui 6d9b7f4
chore: remove unused `_has_tool_calls` from AgentSpeaker
philipph-askui 77239f0
Merge branch 'main' into chore/act_conversation_with_caching
philipph-askui 70293a4
fix: linting issue (Line too long)
philipph-askui c5728db
chore: remove unused local `speaker` variable
philipph-askui 3c8f50a
fix: run pdm install
philipph-askui 1c1c687
chore: make description and name public member variables of speakers …
philipph-askui 979ebba
chore: remove code quality (remove try-except, add isEnabledFor check…
philipph-askui ece5dfd
rename `_conclude_control_loop` to `_teardown_control_loop`
philipph-askui 7998ac0
chore: refactor `_sanitize_message_for_api` into new `from_message_pa…
philipph-askui 8d75ab6
fix: update docs to reflect latest changes
philipph-askui cb5f1a6
fix: remove try-except in CacheExecutor
philipph-askui 62b817c
chore: add inline comment in ContentBlock conversion of anthropic mes…
philipph-askui 7e04fb4
fix: exclude agent settings from telemetry as it cant be converted to…
philipph-askui 0a286d3
fix: bug in agent response status
philipph-askui 7d8c054
chore: set correct logger name
philipph-askui 698596c
chore: clean up logging in cache verification
philipph-askui b6998bf
fix: refines cache use prompt to prevent the model from using the wro…
philipph-askui 0b02f97
feat: adds hint to "Original" token values that this was the consumed…
philipph-askui b7d06af
chore: removes outdated `SIMPLIFICATION_CONCEPT.md`
philipph-askui 0e42685
fix: index of docs in overivew to align with filenames
philipph-askui c85141f
feat: change default model for vlm_providers to `claude-sonnet-4-6`
philipph-askui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,5 +169,6 @@ reports/ | |
| /askui_chat.db-shm | ||
| /askui_chat.db-wal | ||
| .cache/ | ||
| .askui_cache/* | ||
|
|
||
| bom.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # Callbacks | ||
|
|
||
| Callbacks provide hooks into the agent's conversation lifecycle, similar to PyTorch Lightning's callback system. Use them for logging, monitoring, custom metrics, or extending agent behavior. | ||
|
|
||
| ## Usage | ||
|
|
||
| Subclass `ConversationCallback` and override the hooks you need: | ||
|
|
||
| ```python | ||
| from askui import ComputerAgent, ConversationCallback | ||
|
|
||
| class MetricsCallback(ConversationCallback): | ||
| def on_step_start(self, conversation, step_index): | ||
| print(f"Step {step_index} starting...") | ||
|
|
||
| def on_step_end(self, conversation, step_index, result): | ||
| print(f"Step {step_index} finished: {result.status}") | ||
|
|
||
| with ComputerAgent(callbacks=[MetricsCallback()]) as agent: | ||
| agent.act("Open the settings menu") | ||
| ``` | ||
|
|
||
| ## Available Hooks | ||
|
programminx-askui marked this conversation as resolved.
|
||
|
|
||
| | Hook | When Called | Parameters | | ||
| |------|-------------|------------| | ||
| | `on_conversation_start` | After setup, before control loop | `conversation` | | ||
| | `on_conversation_end` | After control loop, before cleanup | `conversation` | | ||
| | `on_control_loop_start` | Before the iteration loop begins | `conversation` | | ||
| | `on_control_loop_end` | After the iteration loop ends | `conversation` | | ||
| | `on_step_start` | Before each step execution | `conversation`, `step_index` | | ||
| | `on_step_end` | After each step execution | `conversation`, `step_index`, `result` | | ||
| | `on_tool_execution_start` | Before tools are executed | `conversation`, `tool_names` | | ||
| | `on_tool_execution_end` | After tools are executed | `conversation`, `tool_names` | | ||
|
|
||
| ### Parameters | ||
|
|
||
| - **`conversation`**: The `Conversation` instance with access to messages, settings, and state | ||
| - **`step_index`**: Zero-based index of the current step | ||
| - **`result`**: `SpeakerResult` containing `status`, `messages_to_add`, and `usage` | ||
| - **`tool_names`**: List of tool names being executed | ||
|
|
||
| ## Example: Timing Callback | ||
|
|
||
| ```python | ||
| import time | ||
| from askui import ComputerAgent, ConversationCallback | ||
|
|
||
| class TimingCallback(ConversationCallback): | ||
|
programminx-askui marked this conversation as resolved.
|
||
| def __init__(self): | ||
| self.start_time = None | ||
| self.step_times = [] | ||
|
|
||
| def on_conversation_start(self, conversation): | ||
| self.start_time = time.time() | ||
|
|
||
| def on_step_start(self, conversation, step_index): | ||
| self._step_start = time.time() | ||
|
|
||
| def on_step_end(self, conversation, step_index, result): | ||
| elapsed = time.time() - self._step_start | ||
| self.step_times.append(elapsed) | ||
| print(f"Step {step_index}: {elapsed:.2f}s") | ||
|
|
||
| def on_conversation_end(self, conversation): | ||
| total = time.time() - self.start_time | ||
| print(f"Total: {total:.2f}s across {len(self.step_times)} steps") | ||
|
|
||
| with ComputerAgent(callbacks=[TimingCallback()]) as agent: | ||
| agent.act("Search for documents") | ||
| ``` | ||
|
|
||
| ## Multiple Callbacks | ||
|
|
||
| Pass multiple callbacks to combine behaviors: | ||
|
|
||
| ```python | ||
| with ComputerAgent(callbacks=[TimingCallback(), MetricsCallback()]) as agent: | ||
| agent.act("Complete the form") | ||
| ``` | ||
|
|
||
| Callbacks are called in the order they are provided. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.