2121from typing_extensions import override
2222from v3 .callbacks .response_handlers import (agent_response_callback ,
2323 streaming_agent_response_callback )
24- from v3 .config .settings import (connection_config , current_user_id ,
25- orchestration_config )
24+ from v3 .config .settings import connection_config , orchestration_config
2625from v3 .models .messages import (UserClarificationRequest ,
2726 UserClarificationResponse , WebsocketMessageType )
2827
@@ -94,11 +93,11 @@ class ProxyAgent(Agent):
9493 """Simple proxy agent that prompts for human clarification."""
9594
9695 # Declare as Pydantic field
97- user_id : Optional [ str ] = Field (default = None , description = "User ID for WebSocket messaging" )
96+ user_id : str = Field (default = None , description = "User ID for WebSocket messaging" )
9897
99- def __init__ (self , user_id : str = None , ** kwargs ):
100- # Get user_id from parameter or context , fallback to empty string
101- effective_user_id = user_id or current_user_id . get () or ""
98+ def __init__ (self , user_id : str , ** kwargs ):
99+ # Get user_id from parameter, fallback to empty string
100+ effective_user_id = user_id or ""
102101 super ().__init__ (
103102 name = "ProxyAgent" ,
104103 description = "Call this agent when you need to clarify requests by asking the human user for more information. Ask it for more details about any unclear requirements, missing information, or if you need the user to elaborate on any aspect of the task." ,
@@ -119,15 +118,15 @@ def _create_message_content(self, content: str, thread_id: str = None) -> ChatMe
119118 async def _trigger_response_callbacks (self , message_content : ChatMessageContent ):
120119 """Manually trigger the same response callbacks used by other agents."""
121120 # Get current user_id dynamically instead of using stored value
122- current_user = current_user_id . get () or self .user_id or ""
121+ current_user = self .user_id or ""
123122
124123 # Trigger the standard agent response callback
125124 agent_response_callback (message_content , current_user )
126125
127126 async def _trigger_streaming_callbacks (self , content : str , is_final : bool = False ):
128127 """Manually trigger streaming callbacks for real-time updates."""
129128 # Get current user_id dynamically instead of using stored value
130- current_user = current_user_id . get () or self .user_id or ""
129+ current_user = self .user_id or ""
131130 streaming_message = StreamingChatMessageContent (
132131 role = AuthorRole .ASSISTANT ,
133132 content = content ,
@@ -158,7 +157,7 @@ async def invoke(self, message: str,*, thread: AgentThread | None = None,**kwarg
158157 await connection_config .send_status_update_async ({
159158 "type" : WebsocketMessageType .USER_CLARIFICATION_REQUEST ,
160159 "data" : clarification_message
161- }, user_id = current_user_id . get () , message_type = WebsocketMessageType .USER_CLARIFICATION_REQUEST )
160+ }, user_id = self . user_id , message_type = WebsocketMessageType .USER_CLARIFICATION_REQUEST )
162161
163162 # Get human input
164163 human_response = await self ._wait_for_user_clarification (clarification_message .request_id )
@@ -206,7 +205,7 @@ async def invoke_stream(self, messages, thread=None, **kwargs) -> AsyncIterator[
206205 await connection_config .send_status_update_async ({
207206 "type" : WebsocketMessageType .USER_CLARIFICATION_REQUEST ,
208207 "data" : clarification_message
209- }, user_id = current_user_id . get () , message_type = WebsocketMessageType .USER_CLARIFICATION_REQUEST )
208+ }, user_id = self . user_id , message_type = WebsocketMessageType .USER_CLARIFICATION_REQUEST )
210209
211210 # Get human input - replace with websocket call when available
212211 human_response = await self ._wait_for_user_clarification (clarification_message .request_id )
0 commit comments