Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

feat(symphony): 增加先检索,后编排,分别调用工具的功能

lin-xiaoyu6a61e4b2e55f
diff --git a/jiuwenswarm/agents/harness/common/prompt/prompt_builder.py b/jiuwenswarm/agents/harness/common/prompt/prompt_builder.py
index ea74c695a5..e0907b0c35 100644
--- a/jiuwenswarm/agents/harness/common/prompt/prompt_builder.py
+++ b/jiuwenswarm/agents/harness/common/prompt/prompt_builder.py
@@ -41,10 +41,13 @@ When the user says to use skill(s) or 技能, or when you judge that skill
capabilities, skill chaining, skill ordering, or a specialized toolchain could
help complete the task, you MUST call `symphony_compose_score` with the original
user task as `query` before answering.
-Do not manually list skill names, inspect skill folders, choose a skill chain,
-or recommend skills before calling `symphony_compose_score`. After it returns,
-present its returned `content` directly to the user. If Symphony reports
-missing inputs, ask for those inputs.
+When installed-skill retrieval is available and can narrow the search space,
+use `skill_branch_peek` / `skill_branch_explore` to shortlist candidate skills
+first, then pass the selected `worker_id` values as
+`symphony_compose_score.candidate_skill_ids`. Do not inspect skill folders
+manually or choose the execution chain yourself; Symphony owns ordering and
+graph composition. After it returns, present its returned `content` directly to
+the user. If Symphony reports missing inputs, ask for those inputs.
If Symphony reports no suitable candidates, a missing capability, or caveats
that point to a skill gap, use `search_skill` to discover external skills. When
diff --git a/jiuwenswarm/agents/harness/common/tools/skill_retrieval_toolkits.py b/jiuwenswarm/agents/harness/common/tools/skill_retrieval_toolkits.py
index b26fb0c212..48afd33a70 100644
--- a/jiuwenswarm/agents/harness/common/tools/skill_retrieval_toolkits.py
+++ b/jiuwenswarm/agents/harness/common/tools/skill_retrieval_toolkits.py
@@ -102,6 +102,8 @@ class SkillRetrievalToolkit:
"When the result contains a 'skills' section, those entries are installed skills, not branch ids; "
"shortlist by Name and Description, then read a returned SKILL.md only after the skill "
"looks likely useful. "
+ "To guide Symphony composition, pass shortlisted skill worker_id values to "
+ "symphony_compose_score.candidate_skill_ids. "
"Do not read every skill or explore skill names as branch ids. "
"This is not an execution tool or a full execution plan. If the index is missing or stale, "
"follow the returned instruction to call skill_index_build once, then retry."
diff --git a/jiuwenswarm/agents/harness/common/tools/symphony_toolkits.py b/jiuwenswarm/agents/harness/common/tools/symphony_toolkits.py
index e970a571c5..84b70a16a8 100644
--- a/jiuwenswarm/agents/harness/common/tools/symphony_toolkits.py
+++ b/jiuwenswarm/agents/harness/common/tools/symphony_toolkits.py
@@ -372,6 +372,7 @@ class SymphonyToolkit:
payload,
(
"enabled",
+ "source",
"used",
"candidate_skill_ids",
"candidate_count",
@@ -525,7 +526,12 @@ class SymphonyToolkit:
or fallback
).strip()
- async def plan(self, query: str, mode: str | None = None) -> dict[str, Any]:
+ async def plan(
+ self,
+ query: str,
+ mode: str | None = None,
+ candidate_skill_ids: list[str] | None = None,
+ ) -> dict[str, Any]:
if not self.is_enabled():
return self._compact_plan_payload(self._disabled_payload("symphony.plan"))
status = await self.score_status()
@@ -555,6 +561,11 @@ class SymphonyToolkit:
mode_text = str(mode or "").strip()
if mode_text:
params["mode"] = mode_text
+ normalized_candidate_skill_ids = _normalize_candidate_skill_ids(
+ candidate_skill_ids
+ )
+ if normalized_candidate_skill_ids is not None:
+ params["candidate_skill_ids"] = normalized_candidate_skill_ids
payload = await self._call_rpc("symphony.plan", params)
if isinstance(payload, dict):
payload.setdefault("score_status", status)
@@ -610,13 +621,15 @@ class SymphonyToolkit:
(
"MUST call before answering when the user says to use skill(s) "
"or 技能, or when skill capabilities, skill chaining, skill ordering, "
- "or a specialized toolchain could help complete the task. Do not manually "
- "list skill names or choose a skill chain before calling this tool. This is "
- "the Symphony entrypoint: it reads the score, refreshes stale or missing "
- "scores, then composes the skill execution graph. If no suitable candidates "
- "or a missing capability is reported, use search_skill to discover external "
- "skills; when installing a discovered skill is appropriate, call install_skill, "
- "then call symphony_refresh_score and retry this tool with the original query. "
+ "or a specialized toolchain could help complete the task. Use skill_branch_peek "
+ "and skill_branch_explore first when installed-skill retrieval can narrow "
+ "the candidate skills, then pass returned worker_id values as candidate_skill_ids. "
+ "This is the Symphony composition entrypoint: it reads the score, refreshes stale "
+ "or missing scores, then composes the skill execution graph from the provided "
+ "candidates or a default score subgraph. If no suitable candidates or a missing "
+ "capability is reported, use search_skill to discover external skills; when "
+ "installing a discovered skill is appropriate, call install_skill, then call "
+ "symphony_refresh_score and retry this tool with the original query. "
"After it returns, present its content result directly to the user; "
"do not call individual skill tools just to manually recreate the plan. "
"Skip only clearly ordinary tasks that do not benefit from skill capabilities."
@@ -636,6 +649,15 @@ class SymphonyToolkit:
"supports fast planning only."
),
},
+ "candidate_skill_ids": {
+ "type": "array",
+ "items": {"type": "string"},
+ "description": (
+ "Optional installed skill worker_id values returned by "
+ "skill_branch_explore. When provided, Symphony composes "
+ "from these candidate skills and their eligible neighbors."
+ ),
+ },
},
"required": ["query"],
},
@@ -664,3 +686,19 @@ def _copy_compact_fields(
continue
compact[key] = value
return compact
+
+
+def _normalize_candidate_skill_ids(values: Any) -> list[str] | None:
+ if values is None:
+ return None
+ if not isinstance(values, (list, tuple)):
+ return []
+ output: list[str] = []
+ seen: set[str] = set()
+ for value in values:
+ current_skill_id = str(value or "").strip()
+ if not current_skill_id or current_skill_id in seen:
+ continue
+ seen.add(current_skill_id)
+ output.append(current_skill_id)
+ return output
diff --git a/jiuwenswarm/extensions/symphony/extension.py b/jiuwenswarm/extensions/symphony/extension.py
index 64b2e2b301..58f8b62b60 100644
--- a/jiuwenswarm/extensions/symphony/extension.py
+++ b/jiuwenswarm/extensions/symphony/extension.py
@@ -29,6 +29,22 @@ SYMPHONY_PLAN = "symphony.plan"
logger = logging.getLogger(__name__)
+def _candidate_skill_ids_from_params(value: Any) -> list[str] | None:
+ if value is None:
+ return None
+ if not isinstance(value, (list, tuple)):
+ return []
+ output: list[str] = []
+ seen: set[str] = set()
+ for item in value:
+ current_skill_id = str(item or "").strip()
+ if not current_skill_id or current_skill_id in seen:
+ continue
+ seen.add(current_skill_id)
+ output.append(current_skill_id)
+ return output
+
+
class SymphonyExtension(BaseExtension):
"""Register explicit Symphony RPC methods."""
@@ -149,6 +165,9 @@ class SymphonyExtension(BaseExtension):
query = str(params.get("query") or "").strip()
if not query:
return {"success": False, "detail": "query is required"}
+ candidate_skill_ids = _candidate_skill_ids_from_params(
+ params.get("candidate_skill_ids")
+ )
config = load_symphony_config()
score_dir = config.paths.score_dir
orchestration_config = config.orchestration
@@ -182,6 +201,7 @@ class SymphonyExtension(BaseExtension):
query,
LLMConfig.from_default_model(),
orchestration_config=orchestration_config,
+ candidate_skill_ids=candidate_skill_ids,
)
if payload.get("success") is False:
return {
diff --git a/jiuwenswarm/extensions/symphony/skills/symphony-assistant/SKILL.md b/jiuwenswarm/extensions/symphony/skills/symphony-assistant/SKILL.md
index b74beae395..2d262c0174 100644
--- a/jiuwenswarm/extensions/symphony/skills/symphony-assistant/SKILL.md
+++ b/jiuwenswarm/extensions/symphony/skills/symphony-assistant/SKILL.md
@@ -5,6 +5,9 @@ allowed_tools:
- symphony_compose_score
- symphony_read_score
- symphony_refresh_score
+ - skill_branch_peek
+ - skill_branch_explore
+ - skill_index_build
---
# Symphony Assistant
@@ -14,17 +17,18 @@ Use this skill when a task may benefit from selecting, combining, ordering, or d
## Workflow
1. If the user says to use skill(s) or 技能, or if skill capabilities, skill chaining, skill ordering, or a specialized toolchain could help, always call `symphony_compose_score` with the original user task as `query`.
-2. Do not manually list skill folders, list skill names, or choose a skill chain before calling `symphony_compose_score`.
-3. Treat `symphony_compose_score` as the only planning entrypoint: it reads the Symphony score, refreshes missing or stale scores, and returns the user-facing plan Markdown and Mermaid execution graph.
-4. The `symphony_compose_score` result may already be displayed directly to the user; otherwise, present its returned `content` directly.
-5. Treat the returned plan, Mermaid graph, structured missing inputs, and caveats as the source of truth.
-6. Do not call individual skill tools just to manually recreate or verify the Symphony plan.
-7. If Symphony reports missing inputs, ask the user for those inputs instead of inventing them.
-8. If Symphony reports no suitable candidates, a missing capability, or caveats that point to a skill gap, use `search_skill` to discover external skills. When installing a discovered skill is appropriate, call `install_skill`; after a successful install, call `symphony_refresh_score` and then call `symphony_compose_score` again with the original user task.
-9. For clearly ordinary tasks that do not benefit from skill capabilities, do not use Symphony.
+2. When installed-skill retrieval is available and can narrow the search space, use `skill_branch_peek` / `skill_branch_explore` first, then pass selected candidate `worker_id` values as `symphony_compose_score.candidate_skill_ids`.
+3. Do not manually inspect skill folders or choose the execution chain yourself; Symphony owns ordering and graph composition.
+4. Treat `symphony_compose_score` as the planning entrypoint: it reads the Symphony score, refreshes missing or stale scores, and returns the user-facing plan Markdown and Mermaid execution graph.
+5. The `symphony_compose_score` result may already be displayed directly to the user; otherwise, present its returned `content` directly.
+6. Treat the returned plan, Mermaid graph, structured missing inputs, and caveats as the source of truth.
+7. Do not call individual skill tools just to manually recreate or verify the Symphony plan.
+8. If Symphony reports missing inputs, ask the user for those inputs instead of inventing them.
+9. If Symphony reports no suitable candidates, a missing capability, or caveats that point to a skill gap, use `search_skill` to discover external skills. When installing a discovered skill is appropriate, call `install_skill`; after a successful install, call `symphony_refresh_score` and then call `symphony_compose_score` again with the original user task.
+10. For clearly ordinary tasks that do not benefit from skill capabilities, do not use Symphony.
## Notes
-- `symphony_compose_score` reads the current Symphony score, refreshes it when missing or stale, and then plans the skill execution graph.
+- `symphony_compose_score` reads the current Symphony score, refreshes it when missing or stale, and then plans the skill execution graph from provided `candidate_skill_ids` or the default score subgraph.
- External skills must first be discovered and installed through the skill tools, then added to the score with `symphony_refresh_score`, before they can participate in Symphony planning.
- Use `symphony_read_score` and `symphony_refresh_score` directly only when the user explicitly asks to read or refresh the Symphony score.
diff --git a/jiuwenswarm/symphony/orchestration/service.py b/jiuwenswarm/symphony/orchestration/service.py
index 78258f768e..e097eccd28 100644
--- a/jiuwenswarm/symphony/orchestration/service.py
+++ b/jiuwenswarm/symphony/orchestration/service.py
@@ -2,18 +2,14 @@
from __future__ import annotations
-import asyncio
from pathlib import Path
-from typing import Any
+from typing import Any, Sequence
from jiuwenswarm.symphony.config import SymphonyOrchestrationConfig
from jiuwenswarm.symphony.llm import LLMConfig
from jiuwenswarm.symphony.orchestration import load_score_artifacts
from jiuwenswarm.symphony.orchestration.execution_graph import build_execution_graph
from jiuwenswarm.symphony.orchestration.planning.fast import FastOneShotPlanner
-from jiuwenswarm.symphony.orchestration.skill_retrieval import (
- select_orchestration_skill_candidates,
-)
from jiuwenswarm.symphony.orchestration.planning.utils import clamp
@@ -28,12 +24,12 @@ async def plan_from_score(
llm_client: Any | None = None,
ranker: Any | None = None,
orchestration_config: SymphonyOrchestrationConfig | None = None,
+ candidate_skill_ids: Sequence[str] | None = None,
) -> dict[str, Any]:
"""Run online planning from an existing Symphony score."""
if orchestration_config is not None:
top_k = orchestration_config.top_k
- max_depth = orchestration_config.max_depth
min_edge_confidence = orchestration_config.min_edge_confidence
mode = orchestration_config.mode if orchestration_config is not None else "fast"
@@ -41,13 +37,9 @@ async def plan_from_score(
if mode != "fast":
raise ValueError(f"Unsupported orchestration mode: {mode}")
- skill_retrieval = await asyncio.to_thread(
- select_orchestration_skill_candidates,
- query=query,
- artifacts=artifacts,
- )
- candidate_skill_ids = (
- skill_retrieval.candidate_skill_ids if skill_retrieval.used else None
+ selected_candidate_skill_ids, skill_retrieval = _input_candidate_summary(
+ candidate_skill_ids,
+ known_skill_ids=set(artifacts.skill_by_id),
)
result = await FastOneShotPlanner(
artifacts,
@@ -55,8 +47,50 @@ async def plan_from_score(
llm_client=llm_client,
min_edge_confidence=clamp(min_edge_confidence),
top_k=max(1, int(top_k)),
- candidate_skill_ids=candidate_skill_ids,
+ candidate_skill_ids=selected_candidate_skill_ids,
).plan(query)
- result["skill_retrieval"] = skill_retrieval.to_dict()
+ result["skill_retrieval"] = skill_retrieval
result["execution_graph"] = build_execution_graph(result, artifacts)
return result
+
+
+def _input_candidate_summary(
+ values: Sequence[str] | None,
+ *,
+ known_skill_ids: set[str],
+) -> tuple[tuple[str, ...] | None, dict[str, Any]]:
+ normalized = _normalize_candidate_skill_ids(values)
+ selected = tuple(
+ current_skill_id
+ for current_skill_id in normalized
+ if current_skill_id in known_skill_ids
+ )
+ fallback_reason = ""
+ if values is None:
+ fallback_reason = "candidate_skill_ids not provided"
+ elif not normalized:
+ fallback_reason = "candidate_skill_ids is empty"
+ elif not selected:
+ fallback_reason = "candidate_skill_ids did not match current score"
+
+ return selected or None, {
+ "source": "input",
+ "used": bool(selected),
+ "candidate_skill_ids": list(selected),
+ "candidate_count": len(selected),
+ "fallback_reason": fallback_reason,
+ }
+
+
+def _normalize_candidate_skill_ids(values: Sequence[str] | None) -> tuple[str, ...]:
+ if values is None:
+ return ()
+ output: list[str] = []
+ seen: set[str] = set()
+ for value in values:
+ current_skill_id = str(value or "").strip()
+ if not current_skill_id or current_skill_id in seen:
+ continue
+ seen.add(current_skill_id)
+ output.append(current_skill_id)
+ return tuple(output)
diff --git a/tests/unit_tests/symphony/test_extension.py b/tests/unit_tests/symphony/test_extension.py
index 2dbdb18747..a04b24d2b2 100644
--- a/tests/unit_tests/symphony/test_extension.py
+++ b/tests/unit_tests/symphony/test_extension.py
@@ -156,6 +156,51 @@ def test_plan_uses_requested_fast_mode(monkeypatch, tmp_path):
assert seen["orchestration_config"].mode == "fast"
+def test_plan_passes_candidate_skill_ids(monkeypatch, tmp_path):
+ configured_score_dir = tmp_path / "configured"
+ seen = {}
+ monkeypatch.setattr(
+ "jiuwenswarm.extensions.symphony.extension.load_symphony_config",
+ lambda: symphony_config_from_dict(
+ {"paths": {"score_dir": str(configured_score_dir)}}
+ ),
+ )
+ monkeypatch.setattr(
+ "jiuwenswarm.extensions.symphony.extension.load_score_artifacts",
+ lambda score_dir: {"score_dir": str(score_dir)},
+ )
+ monkeypatch.setattr(
+ "jiuwenswarm.extensions.symphony.extension.LLMConfig.from_default_model",
+ lambda: object(),
+ )
+
+ async def fake_plan_from_score(score_dir, query, received_llm_config, **kwargs):
+ del score_dir, query, received_llm_config
+ seen["candidate_skill_ids"] = kwargs["candidate_skill_ids"]
+ return {
+ "status": "ready",
+ "recommended_plans": [],
+ "execution_graph": {"edges": []},
+ }
+
+ monkeypatch.setattr(
+ "jiuwenswarm.extensions.symphony.extension.plan_from_score",
+ fake_plan_from_score,
+ )
+
+ result = asyncio.run(
+ SymphonyExtension().plan(
+ {
+ "query": "do work",
+ "candidate_skill_ids": [" skill-a ", "", "skill-a", "skill-b"],
+ }
+ )
+ )
+
+ assert result["success"] is True
+ assert seen["candidate_skill_ids"] == ["skill-a", "skill-b"]
+
+
def test_plan_rejects_requested_beam_mode(monkeypatch, tmp_path):
configured_score_dir = tmp_path / "configured"
monkeypatch.setattr(
diff --git a/tests/unit_tests/symphony/test_service.py b/tests/unit_tests/symphony/test_service.py
index b0ad6c5869..3e190794d7 100644
--- a/tests/unit_tests/symphony/test_service.py
+++ b/tests/unit_tests/symphony/test_service.py
@@ -6,9 +6,6 @@ import pytest
from jiuwenswarm.symphony.config import SymphonyOrchestrationConfig
from jiuwenswarm.symphony.orchestration import service
from jiuwenswarm.symphony.orchestration.artifacts import ScoreArtifacts
-from jiuwenswarm.symphony.orchestration.skill_retrieval import (
- OrchestrationSkillRetrievalSelection,
-)
class _FakeLLMClient:
@@ -288,7 +285,7 @@ async def test_plan_from_score_fast_rejects_low_confidence_edge_once(
assert "illegal can_feed edges" in result["detail"]
-async def test_plan_from_score_fast_uses_retrieved_candidates_and_neighbors(
+async def test_plan_from_score_fast_uses_input_candidates_and_neighbors(
monkeypatch,
tmp_path,
):
@@ -330,15 +327,6 @@ async def test_plan_from_score_fast_uses_retrieved_candidates_and_neighbors(
}
)
monkeypatch.setattr(service, "load_score_artifacts", lambda score_dir: artifacts)
- monkeypatch.setattr(
- service,
- "select_orchestration_skill_candidates",
- lambda **kwargs: OrchestrationSkillRetrievalSelection(
- enabled=True,
- used=True,
- candidate_skill_ids=("skill-b",),
- ),
- )
result = await service.plan_from_score(
tmp_path,
@@ -348,16 +336,134 @@ async def test_plan_from_score_fast_uses_retrieved_candidates_and_neighbors(
mode="fast",
min_edge_confidence=0.7,
),
+ candidate_skill_ids=["skill-b"],
)
prompt_payload = json.loads(llm.calls[0]["user_content"])
prompt_skill_ids = {skill["id"] for skill in prompt_payload["skills"]}
assert prompt_skill_ids == {"skill-a", "skill-b", "skill-c"}
assert "skill-d" not in prompt_skill_ids
+ assert result["skill_retrieval"]["source"] == "input"
assert result["skill_retrieval"]["used"] is True
assert result["skill_retrieval"]["candidate_skill_ids"] == ["skill-b"]
+async def test_plan_from_score_fast_without_candidates_uses_default_subgraph(
+ monkeypatch,
+ tmp_path,
+):
+ artifacts = _artifacts(tmp_path)
+ artifacts.skills.extend(
+ [
+ {
+ "id": "skill-d",
+ "name": "Delta Skill",
+ "description": "Unrelated high-confidence source.",
+ "inputs": [],
+ "outputs": [{"name": "delta", "type": "markdown"}],
+ },
+ {
+ "id": "skill-e",
+ "name": "Echo Skill",
+ "description": "Unrelated high-confidence target.",
+ "inputs": [{"name": "delta", "type": "markdown"}],
+ "outputs": [{"name": "echo", "type": "markdown"}],
+ },
+ ]
+ )
+ artifacts.graph["edges"].append(
+ {
+ "type": "can_feed",
+ "source": "skill-d",
+ "target": "skill-e",
+ "confidence": 0.99,
+ "method": "llm",
+ "evidence": {"reasons": ["unrelated"]},
+ }
+ )
+ llm = _FakeLLMClient(
+ {
+ "title": "Default fast plan",
+ "status": "ready",
+ "steps": [{"skill_id": "skill-d", "reason": "Default seed."}],
+ "can_feed_edges": [],
+ }
+ )
+ monkeypatch.setattr(service, "load_score_artifacts", lambda score_dir: artifacts)
+
+ result = await service.plan_from_score(
+ tmp_path,
+ "use beta",
+ llm_client=llm,
+ orchestration_config=SymphonyOrchestrationConfig(
+ mode="fast",
+ min_edge_confidence=0.7,
+ ),
+ )
+
+ prompt_payload = json.loads(llm.calls[0]["user_content"])
+ prompt_skill_ids = {skill["id"] for skill in prompt_payload["skills"]}
+ assert {"skill-d", "skill-e"}.issubset(prompt_skill_ids)
+ assert result["skill_retrieval"] == {
+ "source": "input",
+ "used": False,
+ "candidate_skill_ids": [],
+ "candidate_count": 0,
+ "fallback_reason": "candidate_skill_ids not provided",
+ }
+
+
+ ("candidate_skill_ids", "fallback_reason"),
+ [
+ ([], "candidate_skill_ids is empty"),
+ (
+ ["missing-skill", "missing-skill", ""],
+ "candidate_skill_ids did not match current score",
+ ),
+ ],
+)
+async def test_plan_from_score_fast_falls_back_for_empty_or_unknown_candidates(
+ monkeypatch,
+ tmp_path,
+ candidate_skill_ids,
+ fallback_reason,
+):
+ artifacts = _artifacts(tmp_path)
+ llm = _FakeLLMClient(
+ {
+ "title": "Fallback fast plan",
+ "status": "ready",
+ "steps": [{"skill_id": "skill-a", "reason": "Fallback seed."}],
+ "can_feed_edges": [],
+ }
+ )
+ monkeypatch.setattr(service, "load_score_artifacts", lambda score_dir: artifacts)
+
+ result = await service.plan_from_score(
+ tmp_path,
+ "use beta",
+ llm_client=llm,
+ orchestration_config=SymphonyOrchestrationConfig(
+ mode="fast",
+ min_edge_confidence=0.7,
+ ),
+ candidate_skill_ids=candidate_skill_ids,
+ )
+
+ prompt_payload = json.loads(llm.calls[0]["user_content"])
+ prompt_skill_ids = {skill["id"] for skill in prompt_payload["skills"]}
+ assert prompt_skill_ids == {"skill-a", "skill-b", "skill-c"}
+ assert result.get("success") is not False
+ assert result["skill_retrieval"] == {
+ "source": "input",
+ "used": False,
+ "candidate_skill_ids": [],
+ "candidate_count": 0,
+ "fallback_reason": fallback_reason,
+ }
+
+
async def test_plan_from_score_rejects_non_fast_mode(monkeypatch, tmp_path):
artifacts = _artifacts(tmp_path)
monkeypatch.setattr(service, "load_score_artifacts", lambda score_dir: artifacts)
diff --git a/tests/unit_tests/symphony/test_toolkit.py b/tests/unit_tests/symphony/test_toolkit.py
index 8e67c0eacc..16d8242372 100644
--- a/tests/unit_tests/symphony/test_toolkit.py
+++ b/tests/unit_tests/symphony/test_toolkit.py
@@ -133,6 +133,37 @@ def test_toolkit_passes_fast_mode_to_rpc_handler():
assert seen["mode"] == "fast"
+def test_toolkit_passes_candidate_skill_ids_to_rpc_handler():
+ registry = ExtensionRegistry.create_instance(
+ callback_framework=_CallbackFramework(),
+ config={},
+ logger=object(),
+ )
+ seen = {}
+
+ async def handler(params, request=None):
+ del request
+ seen.update(params)
+ return {"success": True, "params": params}
+
+ registry.register_rpc_handler("symphony.plan", handler)
+ registry.register_rpc_handler(
+ "symphony.score_status",
+ lambda _params, request=None: {"success": True, "exists": True, "stale": False},
+ )
+
+ result = asyncio.run(
+ SymphonyToolkit().plan(
+ "use installed skills",
+ candidate_skill_ids=[" skill-a ", "", "skill-a", "skill-b"],
+ )
+ )
+
+ assert result["success"] is True
+ assert "params" not in result
+ assert seen["candidate_skill_ids"] == ["skill-a", "skill-b"]
+
+
def test_toolkit_reports_missing_handler():
ExtensionRegistry.create_instance(
callback_framework=_CallbackFramework(),
@@ -504,7 +535,7 @@ def test_toolkit_plan_returns_compact_plan_and_skill_retrieval():
}
],
"skill_retrieval": {
- "enabled": True,
+ "source": "input",
"used": True,
"candidate_skill_ids": ["skill-1", "skill-2"],
"candidate_count": 2,
@@ -570,6 +601,7 @@ def test_toolkit_plan_returns_compact_plan_and_skill_retrieval():
skill_retrieval = result["skill_retrieval"]
assert "build_progress" not in result["score_status"]
assert result["score_build"] == {"rebuilt": False, "reason": "not_required"}
+ assert skill_retrieval["source"] == "input"
assert skill_retrieval["candidate_skill_ids"] == ["skill-1", "skill-2"]
assert skill_retrieval["candidate_count"] == 2
assert len(skill_retrieval["candidate_records"]) == 10
@@ -731,8 +763,19 @@ def test_toolkit_get_tools_respects_symphony_enabled(monkeypatch):
if tool.card.name == "symphony_compose_score"
)
assert compose_tool.card.input_params["properties"]["mode"]["enum"] == ["fast"]
+ assert compose_tool.card.input_params["properties"]["candidate_skill_ids"] == {
+ "type": "array",
+ "items": {"type": "string"},
+ "description": (
+ "Optional installed skill worker_id values returned by "
+ "skill_branch_explore. When provided, Symphony composes "
+ "from these candidate skills and their eligible neighbors."
+ ),
+ }
description = compose_tool.card.description
assert "skill capabilities, skill chaining, skill ordering" in description
+ assert "skill_branch_explore" in description
+ assert "candidate_skill_ids" in description
assert "search_skill to discover external skills" in description
assert "install_skill" in description
assert "symphony_refresh_score" in description