-
Notifications
You must be signed in to change notification settings - Fork 126
feat: Revamp wait for animation to end tool + tiny fixes #92
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3467557
refactor: replace waitForAnimationToEnd with simpler wait_for_delay fβ¦
plfavreau c4de9b4
fix: add default delay of 1000ms when negative time is provided in waβ¦
plfavreau 177f7ab
refactor: extract agent outcome logic and add to agents_thoughts in wβ¦
plfavreau 9289445
refactor: remove deprecated screenshot handling from mobile agent staβ¦
plfavreau c8b858e
feat: add 60 second max delay cap to wait_for_delay tool
plfavreau 560250a
feat: add async support and error handling to wait_for_delay tool
plfavreau 7d1b876
feat: add validation and logging for unsupported LLM config override β¦
plfavreau d191029
style: remove trailing whitespace in deep_merge_llm_config function
plfavreau 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
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
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
64 changes: 0 additions & 64 deletions
64
minitap/mobile_use/tools/mobile/wait_for_animation_to_end.py
This file was deleted.
Oops, something went wrong.
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,84 @@ | ||
| import asyncio | ||
| from typing import Annotated | ||
|
|
||
| from langchain_core.messages import ToolMessage | ||
| from langchain_core.tools import tool | ||
| from langchain_core.tools.base import InjectedToolCallId | ||
| from langgraph.prebuilt import InjectedState | ||
| from langgraph.types import Command | ||
|
|
||
| from minitap.mobile_use.constants import EXECUTOR_MESSAGES_KEY | ||
| from minitap.mobile_use.context import MobileUseContext | ||
| from minitap.mobile_use.controllers.mobile_command_controller import ( | ||
| wait_for_delay as wait_for_delay_controller, | ||
| ) | ||
| from minitap.mobile_use.graph.state import State | ||
| from minitap.mobile_use.tools.tool_wrapper import ToolWrapper | ||
|
|
||
| MAX_DELAY_MS = 60000 | ||
|
|
||
|
|
||
| def get_wait_for_delay_tool(ctx: MobileUseContext): | ||
| @tool | ||
| async def wait_for_delay( | ||
| tool_call_id: Annotated[str, InjectedToolCallId], | ||
| state: Annotated[State, InjectedState], | ||
| agent_thought: str, | ||
| time_in_ms: int, | ||
| ) -> Command: | ||
| """ | ||
| Wait for a delay in milliseconds. | ||
|
|
||
| This tool pauses execution for a specified number of milliseconds. | ||
| Use this when you need to introduce a controlled delay to allow the UI | ||
| to update after an action, regardless of whether an animation is playing. | ||
|
|
||
| Args: | ||
| time_in_ms: The number of milliseconds to wait. (capped at 60 seconds) | ||
|
|
||
|
|
||
| Example: | ||
| - wait_for_delay with time_in_ms=1000 (waits 1 second) | ||
| - wait_for_delay with time_in_ms=500 (waits 0.5 seconds) | ||
| """ | ||
| if time_in_ms < 0: | ||
| time_in_ms = 1000 | ||
| if time_in_ms > MAX_DELAY_MS: | ||
| time_in_ms = MAX_DELAY_MS | ||
| try: | ||
| await asyncio.to_thread(wait_for_delay_controller, time_in_ms) | ||
| output = None | ||
| has_failed = False | ||
| except Exception as e: | ||
| output = str(e) | ||
| has_failed = True | ||
| agent_outcome = ( | ||
| wait_for_delay_wrapper.on_failure_fn() | ||
| if has_failed | ||
| else wait_for_delay_wrapper.on_success_fn(time_in_ms) | ||
| ) | ||
| tool_message = ToolMessage( | ||
| tool_call_id=tool_call_id, | ||
| content=agent_outcome, | ||
| additional_kwargs={"error": output} if has_failed else {}, | ||
| status="error" if has_failed else "success", | ||
| ) | ||
| return Command( | ||
| update=await state.asanitize_update( | ||
| ctx=ctx, | ||
| update={ | ||
| "agents_thoughts": [agent_thought, agent_outcome], | ||
| EXECUTOR_MESSAGES_KEY: [tool_message], | ||
| }, | ||
| agent="executor", | ||
| ), | ||
| ) | ||
|
|
||
| return wait_for_delay | ||
|
|
||
|
|
||
| wait_for_delay_wrapper = ToolWrapper( | ||
| tool_fn_getter=get_wait_for_delay_tool, | ||
| on_success_fn=lambda delay: f"Successfully waited for {delay} milliseconds.", | ||
| on_failure_fn=lambda: "Failed to wait for delay.", | ||
| ) |
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.