Skip to content

Commit 4029647

Browse files
chore: refactor control loop and delete legacy code (custom_agent and on_message_cb)
1 parent ee78cbf commit 4029647

6 files changed

Lines changed: 49 additions & 377 deletions

File tree

src/askui/agent_base.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from askui.container import telemetry
1414
from askui.locators.locators import Locator
1515
from askui.models.shared.agent_message_param import MessageParam
16-
from askui.models.shared.agent_on_message_cb import OnMessageCb
1716
from askui.models.shared.conversation import Conversation, Speakers
1817
from askui.models.shared.settings import (
1918
ActSettings,
@@ -109,13 +108,12 @@ def __init__(
109108
self.locate_settings = LocateSettings()
110109
self.caching_settings = CachingSettings()
111110

112-
@telemetry.record_call(exclude={"goal", "on_message", "act_settings", "tools"})
111+
@telemetry.record_call(exclude={"goal", "act_settings", "tools"})
113112
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
114113
def act(
115114
self,
116115
goal: Annotated[str | list[MessageParam], Field(min_length=1)],
117116
act_settings: ActSettings | None = None,
118-
on_message: OnMessageCb | None = None,
119117
tools: list[Tool] | ToolCollection | None = None,
120118
caching_settings: CachingSettings | None = None,
121119
) -> None:
@@ -134,9 +132,6 @@ def act(
134132
act_model (ActModel | None, optional): Model to use for this act
135133
execution.
136134
Overrides the agent's default model if provided.
137-
on_message (OnMessageCb | None, optional): Callback for new messages. If
138-
it returns `None`, stops and does not add the message. Cannot be used
139-
with caching_settings strategy "record" or "both".
140135
tools (list[Tool] | ToolCollection | None, optional): The tools for the
141136
agent. Defaults to default tools depending on the selected model.
142137
caching_settings (CachingSettings | None, optional): The caching settings
@@ -153,8 +148,6 @@ def act(
153148
MaxTokensExceededError: If the model reaches the maximum token limit
154149
defined in the agent settings.
155150
ModelRefusalError: If the model refuses to process the request.
156-
ValueError: If on_message callback is provided with caching strategy
157-
"record" or "both".
158151
159152
Example:
160153
Basic usage without caching:
@@ -248,9 +241,8 @@ def act(
248241
self._conversation.cache_manager = cache_manager
249242

250243
# Use conversation-based architecture for execution
251-
self._conversation.start(
244+
self._conversation.execute_conversation(
252245
messages=messages,
253-
on_message=on_message,
254246
tools=_tools,
255247
settings=_act_settings,
256248
)

src/askui/custom_agent.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/askui/models/models.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from askui.locators.locators import Locator
88
from askui.models.shared.agent_message_param import MessageParam
9-
from askui.models.shared.agent_on_message_cb import OnMessageCb
109
from askui.models.shared.settings import ActSettings, GetSettings, LocateSettings
1110
from askui.models.shared.tools import ToolCollection
1211
from askui.models.types.geometry import Point, PointList
@@ -140,7 +139,6 @@ def act(
140139
self,
141140
messages: list[MessageParam],
142141
model: str,
143-
on_message: OnMessageCb | None = None,
144142
tools: list[Tool] | None = None,
145143
settings: AgentSettings | None = None,
146144
) -> None:
@@ -155,7 +153,6 @@ def act(
155153
self,
156154
messages: list[MessageParam],
157155
act_settings: ActSettings,
158-
on_message: OnMessageCb | None = None,
159156
tools: ToolCollection | None = None,
160157
) -> None:
161158
"""
@@ -174,14 +171,6 @@ def act(
174171
Args:
175172
messages (list[MessageParam]): The message history to start that
176173
determines the actions and following messages.
177-
on_message (OnMessageCb | None, optional): Callback for new messages
178-
from either an assistant/agent or a user (including
179-
automatic/programmatic tool use, e.g., taking a screenshot).
180-
If it returns `None`, the acting is canceled and `act()` returns
181-
immediately. If it returns a `MessageParam`, this `MessageParma` is
182-
added to the message history and the acting continues based on the
183-
message. The message may be modified by the callback to allow for
184-
directing the assistant/agent or tool use.
185174
tools (ToolCollection | None, optional): The tools for the agent.
186175
Defaults to `None`.
187176
act_settings (ActSettings): The settings for this act operation,

src/askui/models/shared/agent.py

Lines changed: 0 additions & 194 deletions
This file was deleted.

0 commit comments

Comments
 (0)