2424)
2525from semantic_kernel .exceptions .agent_exceptions import AgentThreadOperationException
2626from typing_extensions import override
27- from v3 .callbacks .response_handlers import (
28- agent_response_callback ,
29- streaming_agent_response_callback ,
30- )
31- from v3 .config .settings import connection_config , current_user_id , orchestration_config
32- from v3 .models .messages import (
33- UserClarificationRequest ,
34- UserClarificationResponse ,
35- WebsocketMessageType ,
36- )
27+ from v3 .callbacks .response_handlers import (agent_response_callback ,
28+ streaming_agent_response_callback )
29+ from v3 .config .settings import connection_config , orchestration_config
30+ from v3 .models .messages import (UserClarificationRequest ,
31+ UserClarificationResponse , WebsocketMessageType )
3732
3833
3934class DummyAgentThread (AgentThread ):
@@ -110,13 +105,13 @@ class ProxyAgent(Agent):
110105 """Simple proxy agent that prompts for human clarification."""
111106
112107 # Declare as Pydantic field
113- user_id : Optional [ str ] = Field (
108+ user_id : str = Field (
114109 default = None , description = "User ID for WebSocket messaging"
115110 )
116111
117- def __init__ (self , user_id : str = None , ** kwargs ):
118- # Get user_id from parameter or context , fallback to empty string
119- effective_user_id = user_id or current_user_id . get () or ""
112+ def __init__ (self , user_id : str , ** kwargs ):
113+ # Get user_id from parameter, fallback to empty string
114+ effective_user_id = user_id or ""
120115 super ().__init__ (
121116 name = "ProxyAgent" ,
122117 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." ,
@@ -139,15 +134,15 @@ def _create_message_content(
139134 async def _trigger_response_callbacks (self , message_content : ChatMessageContent ):
140135 """Manually trigger the same response callbacks used by other agents."""
141136 # Get current user_id dynamically instead of using stored value
142- current_user = current_user_id . get () or self .user_id or ""
137+ current_user = self .user_id or ""
143138
144139 # Trigger the standard agent response callback
145140 agent_response_callback (message_content , current_user )
146141
147142 async def _trigger_streaming_callbacks (self , content : str , is_final : bool = False ):
148143 """Manually trigger streaming callbacks for real-time updates."""
149144 # Get current user_id dynamically instead of using stored value
150- current_user = current_user_id . get () or self .user_id or ""
145+ current_user = self .user_id or ""
151146 streaming_message = StreamingChatMessageContent (
152147 role = AuthorRole .ASSISTANT , content = content , name = self .name , choice_index = 0
153148 )
@@ -181,7 +176,7 @@ async def invoke(
181176 "type" : WebsocketMessageType .USER_CLARIFICATION_REQUEST ,
182177 "data" : clarification_message ,
183178 },
184- user_id = current_user_id . get () ,
179+ user_id = self . user_id ,
185180 message_type = WebsocketMessageType .USER_CLARIFICATION_REQUEST ,
186181 )
187182
@@ -238,7 +233,7 @@ async def invoke_stream(
238233 "type" : WebsocketMessageType .USER_CLARIFICATION_REQUEST ,
239234 "data" : clarification_message ,
240235 },
241- user_id = current_user_id . get () ,
236+ user_id = self . user_id ,
242237 message_type = WebsocketMessageType .USER_CLARIFICATION_REQUEST ,
243238 )
244239
0 commit comments