22import logging
33from abc import ABC , abstractmethod
44from datetime import datetime , timezone
5- from typing import Any
65
76from anthropic .types .beta import BetaCacheControlEphemeralParam , BetaTextBlockParam
87from anyio .abc import ObjectStream
3433)
3534from askui .chat .api .settings import Settings
3635from askui .custom_agent import CustomAgent
37- from askui .models .models import ModelName
3836from askui .models .shared .agent_message_param import MessageParam
3937from askui .models .shared .agent_on_message_cb import OnMessageCbParam
4038from askui .models .shared .settings import ActSettings , MessageSettings
@@ -67,6 +65,7 @@ def __init__(
6765 mcp_client_manager_manager : McpClientManagerManager ,
6866 run_service : RunnerRunService ,
6967 settings : Settings ,
68+ model : str | None = None ,
7069 ) -> None :
7170 self ._run_id = run_id
7271 self ._workspace_id = workspace_id
@@ -76,6 +75,7 @@ def __init__(
7675 self ._mcp_client_manager_manager = mcp_client_manager_manager
7776 self ._run_service = run_service
7877 self ._settings = settings
78+ self ._model : str | None = model
7979
8080 def _retrieve_run (self ) -> Run :
8181 return self ._run_service .retrieve (
@@ -164,7 +164,7 @@ def _run_agent_inner() -> None:
164164 )
165165 betas = tools .retrieve_tool_beta_flags ()
166166 system = self ._build_system ()
167- model = self ._settings . model
167+ model = self ._get_model ()
168168 messages = syncify (self ._chat_history_manager .retrieve_message_params )(
169169 workspace_id = self ._workspace_id ,
170170 thread_id = self ._thread_id ,
@@ -269,3 +269,8 @@ async def run(
269269
270270 def _should_abort (self , run : Run ) -> bool :
271271 return run .status in ("cancelled" , "cancelling" , "expired" )
272+
273+ def _get_model (self ) -> str :
274+ if self ._model is not None :
275+ return self ._model
276+ return self ._settings .model
0 commit comments