diff --git a/strix/tools/agents_graph/tools.py b/strix/tools/agents_graph/tools.py index a72b311c3..28a8c622f 100644 --- a/strix/tools/agents_graph/tools.py +++ b/strix/tools/agents_graph/tools.py @@ -350,13 +350,13 @@ async def wait_for_message( # noqa: PLR0911 ) -@function_tool(timeout=120) +@function_tool(timeout=120, strict_mode=False) async def create_agent( ctx: RunContextWrapper, name: str, task: str, inherit_context: bool = True, - skills: list[str] | None = None, + skills: str | list[str] | None = None, ) -> str: """Spawn a specialist child agent to run in parallel. @@ -419,6 +419,23 @@ async def create_agent( default=str, ) + # Tolerate LLM providers that pass array params as JSON-encoded strings. + # Validate decoded shape: reject anything that isn't a list of strings. + if isinstance(skills, str): + original_skills = skills + try: + decoded_skills = json.loads(skills) + except json.JSONDecodeError: + skills = [s.strip() for s in skills.split(",") if s.strip()] + else: + if isinstance(decoded_skills, str): + skills = [decoded_skills] + elif isinstance(decoded_skills, list) and all( + isinstance(skill, str) for skill in decoded_skills + ): + skills = decoded_skills + else: + skills = [original_skills] skill_list = list(skills or []) skill_error = validate_requested_skills(skill_list) if skill_error: diff --git a/strix/tools/load_skill/tool.py b/strix/tools/load_skill/tool.py index 3ef6f9ec0..b3c7e413e 100644 --- a/strix/tools/load_skill/tool.py +++ b/strix/tools/load_skill/tool.py @@ -2,13 +2,15 @@ from __future__ import annotations +import json + from agents import RunContextWrapper, function_tool from strix.skills import load_skills, validate_requested_skills -@function_tool(timeout=10) -async def load_skill(ctx: RunContextWrapper, skills: list[str]) -> str: +@function_tool(timeout=10, strict_mode=False) +async def load_skill(ctx: RunContextWrapper, skills: str | list[str]) -> str: """Return the markdown body of one or more skills as reference material. Use this when you need exact syntax / workflow / payload guidance @@ -25,6 +27,23 @@ async def load_skill(ctx: RunContextWrapper, skills: list[str]) -> str: ``strix/skills//.md``. """ del ctx + # Tolerate LLM providers that pass array params as JSON-encoded strings. + # Validate decoded shape: reject anything that isn't a list of strings. + if isinstance(skills, str): + original_skills = skills + try: + decoded_skills = json.loads(skills) + except json.JSONDecodeError: + skills = [s.strip() for s in skills.split(",") if s.strip()] + else: + if isinstance(decoded_skills, str): + skills = [decoded_skills] + elif isinstance(decoded_skills, list) and all( + isinstance(skill, str) for skill in decoded_skills + ): + skills = decoded_skills + else: + skills = [original_skills] requested = list(skills or []) err = validate_requested_skills(requested) if err: