diff --git a/python/packages/core/agent_framework/_harness/_agent.py b/python/packages/core/agent_framework/_harness/_agent.py index 87280a9fcc..23275f0d10 100644 --- a/python/packages/core/agent_framework/_harness/_agent.py +++ b/python/packages/core/agent_framework/_harness/_agent.py @@ -135,7 +135,7 @@ def _assemble_context_providers( disable_file_access: bool, file_access_store: AgentFileStore | None, skills_provider: SkillsProvider | None, - skills_paths: Sequence[str] | None, + skills_paths: str | Path | Sequence[str | Path] | None, background_agents: Sequence[SupportsAgentRun] | None, background_agents_instructions: str | None, shell_context_provider: ContextProvider | None, @@ -173,7 +173,7 @@ def _assemble_context_providers( if skills_provider: providers.append(skills_provider) if skills_paths: - providers.append(SkillsProvider.from_paths(*skills_paths)) + providers.append(SkillsProvider.from_paths(skills_paths)) # Background agents are opt-in: only added when agents are provided. if background_agents: @@ -263,7 +263,7 @@ def create_harness_agent( disable_file_access: bool = False, file_access_store: AgentFileStore | None = None, skills_provider: SkillsProvider | None = None, - skills_paths: Sequence[str] | None = None, + skills_paths: str | Path | Sequence[str | Path] | None = None, background_agents: Sequence[SupportsAgentRun] | None = None, background_agents_instructions: str | None = None, shell_executor: ShellExecutor | None = None, @@ -377,8 +377,10 @@ def create_harness_agent( skills_provider: Custom SkillsProvider instance for code-defined skills. Can be combined with ``skills_paths`` to aggregate file and code-based skills. skills_paths: Paths for file-based skill discovery (looks for SKILL.md files). - Can be combined with ``skills_provider``. When neither ``skills_provider`` - nor ``skills_paths`` is provided, no SkillsProvider is added. + Accepts a single ``str`` or :class:`~pathlib.Path`, or a sequence of + ``str | Path``. Can be combined with ``skills_provider``. When neither + ``skills_provider`` nor ``skills_paths`` is provided, no SkillsProvider + is added. background_agents: Collection of agents available for background task delegation. When provided, a ``BackgroundAgentsProvider`` is automatically included, enabling the agent to start, monitor, and retrieve results from background tasks. diff --git a/python/packages/core/tests/core/test_harness_agent.py b/python/packages/core/tests/core/test_harness_agent.py index 8213df5888..c55a9fd7d4 100644 --- a/python/packages/core/tests/core/test_harness_agent.py +++ b/python/packages/core/tests/core/test_harness_agent.py @@ -202,6 +202,42 @@ def test_create_harness_agent_skills_paths_adds_provider() -> None: assert SkillsProvider in provider_types +def test_create_harness_agent_skills_paths_single_str() -> None: + """skills_paths should accept a single str (not wrapped in a list).""" + agent = create_harness_agent( + client=_FakeChatClient(), + max_context_window_tokens=128_000, + max_output_tokens=16_384, + skills_paths="./test-skills", + ) + provider_types = [type(p) for p in agent.context_providers] + assert SkillsProvider in provider_types + + +def test_create_harness_agent_skills_paths_single_path(tmp_path: Path) -> None: + """skills_paths should accept a single pathlib.Path (not wrapped in a list).""" + agent = create_harness_agent( + client=_FakeChatClient(), + max_context_window_tokens=128_000, + max_output_tokens=16_384, + skills_paths=tmp_path, + ) + provider_types = [type(p) for p in agent.context_providers] + assert SkillsProvider in provider_types + + +def test_create_harness_agent_skills_paths_sequence_of_paths(tmp_path: Path) -> None: + """skills_paths should accept a sequence of pathlib.Path objects.""" + agent = create_harness_agent( + client=_FakeChatClient(), + max_context_window_tokens=128_000, + max_output_tokens=16_384, + skills_paths=[tmp_path, tmp_path / "sub"], + ) + provider_types = [type(p) for p in agent.context_providers] + assert SkillsProvider in provider_types + + def test_create_harness_agent_disable_compaction() -> None: """disable_compaction=True should exclude CompactionProvider.""" agent = create_harness_agent(