Skip to content

Commit 357b4b9

Browse files
authored
Merge pull request #115 from Fr4nc3/main
Fixing agents
2 parents 20627dd + b795ad3 commit 357b4b9

28 files changed

+547
-432
lines changed

src/backend/app_kernel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
)
3838
from utils_kernel import initialize_runtime_and_context, get_agents, rai_success
3939
from event_utils import track_event_if_configured
40-
from models.agent_types import AgentType
40+
from models.messages_kernel import AgentType
4141
from kernel_agents.agent_factory import AgentFactory
4242

4343
# # Check if the Application Insights Instrumentation Key is set in the environment variables
@@ -242,7 +242,7 @@ async def human_feedback_endpoint(human_feedback: HumanFeedback, request: Reques
242242
agents = await get_agents(human_feedback.session_id, user_id)
243243

244244
# Send the feedback to the human agent
245-
human_agent = agents["HumanAgent"]
245+
human_agent = agents[AgentType.HUMAN.value]
246246

247247
# Convert feedback to JSON for the kernel function
248248
human_feedback_json = human_feedback.json()
@@ -325,7 +325,7 @@ async def human_clarification_endpoint(
325325
agents = await get_agents(human_clarification.session_id, user_id)
326326

327327
# Send the clarification to the planner agent
328-
planner_agent = agents["PlannerAgent"]
328+
planner_agent = agents[AgentType.PLANNER.value]
329329

330330
# Convert clarification to JSON for proper processing
331331
human_clarification_json = human_clarification.json()
@@ -419,7 +419,7 @@ async def approve_step_endpoint(
419419
human_feedback_json = human_feedback.json()
420420

421421
# First process with HumanAgent to update step status
422-
human_agent = agents["HumanAgent"]
422+
human_agent = agents[AgentType.HUMAN.value]
423423
await human_agent.handle_human_feedback(
424424
KernelArguments(human_feedback_json=human_feedback_json)
425425
)

src/backend/kernel_agents/agent_base.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,11 @@ async def kernel_wrapper(kernel_arguments: KernelArguments = None, **kwargs) ->
457457
return kernel_wrapper
458458

459459
@staticmethod
460-
def load_tools_config(agent_type: str, config_path: Optional[str] = None) -> Dict[str, Any]:
460+
def load_tools_config(filename: str, config_path: Optional[str] = None) -> Dict[str, Any]:
461461
"""Load tools configuration from a JSON file.
462462
463463
Args:
464-
agent_type: The type of agent (e.g., "marketing", "hr")
464+
filename: The filename without extension (e.g., "hr", "marketing")
465465
config_path: Optional explicit path to the configuration file
466466
467467
Returns:
@@ -471,16 +471,26 @@ def load_tools_config(agent_type: str, config_path: Optional[str] = None) -> Dic
471471
# Default path relative to the tools directory
472472
current_dir = os.path.dirname(os.path.abspath(__file__))
473473
backend_dir = os.path.dirname(current_dir) # Just one level up to get to backend dir
474-
config_path = os.path.join(backend_dir, "tools", f"{agent_type}_tools.json")
474+
475+
# Normalize filename to avoid issues with spaces and capitalization
476+
# Convert "Hr Agent" to "hr" and "TechSupport Agent" to "tech_support"
477+
logging.debug(f"Normalizing filename: {filename}")
478+
normalized_filename = filename.replace(" ", "_").replace("-", "_").lower()
479+
# If it ends with "_agent", remove it
480+
if normalized_filename.endswith("_agent"):
481+
normalized_filename = normalized_filename[:-6]
482+
logging
483+
config_path = os.path.join(backend_dir, "tools", f"{normalized_filename}_tools.json")
484+
logging.debug(f"Looking for tools config at: {config_path}")
475485

476486
try:
477487
with open(config_path, "r") as f:
478488
return json.load(f)
479489
except Exception as e:
480-
logging.error(f"Error loading {agent_type} tools configuration: {e}")
490+
logging.error(f"Error loading {filename} tools configuration: {e}")
481491
# Return empty default configuration
482492
return {
483-
"agent_name": f"{agent_type.capitalize()}Agent",
493+
"agent_name": f"{filename.capitalize()}Agent",
484494
"system_message": "You are an AI assistant",
485495
"tools": []
486496
}

0 commit comments

Comments
 (0)