Skip to content

Commit f374cb6

Browse files
committed
add thread location
1 parent 7ada010 commit f374cb6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/backend/kernel_agents/agent_base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,11 @@ async def handle_action_request(self, action_request: ActionRequest) -> str:
189189
# chat_history = self._chat_history.copy()
190190

191191
# Call the agent to handle the action
192+
# thread = self.client.agents.create_thread(thread_id=step.session_id)
193+
thread = None
192194
async_generator = self._agent.invoke(
193-
messages=f"{action_request.action}\n\nPlease perform this action"
195+
messages=f"{action_request.action}\n\nPlease perform this action",
196+
thread=thread,
194197
)
195198

196199
response_content = ""
@@ -305,6 +308,13 @@ def create_dynamic_function(
305308
A dynamic async function that can be registered with the semantic kernel
306309
"""
307310

311+
# Truncate function name to 64 characters if it exceeds the limit
312+
if len(name) > 64:
313+
logging.warning(
314+
f"Function name '{name}' exceeds 64 characters (length: {len(name)}). Truncating to 64 characters."
315+
)
316+
name = name[:64]
317+
308318
async def dynamic_function(**kwargs) -> str:
309319
try:
310320
# Format the template with the provided kwargs

src/backend/kernel_agents/planner_agent.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
import semantic_kernel as sk
1313
from semantic_kernel.functions import KernelFunction
1414
from semantic_kernel.functions.kernel_arguments import KernelArguments
15-
15+
from semantic_kernel.agents import (
16+
AzureAIAgent,
17+
AzureAIAgentSettings,
18+
AzureAIAgentThread,
19+
)
1620
from kernel_agents.agent_base import BaseAgent
1721
from context.cosmos_memory_kernel import CosmosMemoryContext
1822
from models.messages_kernel import (
@@ -319,12 +323,15 @@ async def _create_structured_plan(
319323

320324
# Ensure we're using the right pattern for Azure AI agents with semantic kernel
321325
# Properly handle async generation
326+
thread = None
327+
# thread = self.client.agents.create_thread(thread_id=input_task.session_id)
322328
async_generator = self._azure_ai_agent.invoke(
323329
arguments=kernel_args,
324330
settings={
325331
"temperature": 0.0, # Keep temperature low for consistent planning
326332
"max_tokens": 10096, # Ensure we have enough tokens for the full plan
327333
},
334+
thread=thread,
328335
)
329336

330337
# Call invoke with proper keyword arguments and JSON response schema

0 commit comments

Comments
 (0)