feat: Make skill individuals directly accessible to consciousness node (#54)

- Added `available_skills` to `ConsciousnessNodeDeps` and `ForWorkflowEngineInput`.
- Updated `WorkflowRunningEngine` to retrieve all available skills from `GlobalStateMachine` and pass them during `ForWorkflowEngineInput` creation.
- Updated `ConsciousnessNode` to dynamically inject these skills into the system prompt. This allows the AI to correctly insert `skill_individuals` into `PretorWorkflow` steps (as tools for `composite_individual` or `primary_individual`).

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
This commit is contained in:
朝夕 2026-04-28 17:45:15 +08:00 committed by GitHub
parent f5aa396d97
commit 5eab42758b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 2 deletions

View File

@ -78,6 +78,11 @@ class ConsciousnessNode:
)
if ctx.deps.workflow_template:
prompt += f"- 选定工作流模板 (Workflow Template): {ctx.deps.workflow_template}\n"
if ctx.deps.available_skills:
prompt += "\n=== 当前可用 Skill Individual ===\n"
prompt += "你可以直接将以下 Skill Individual 安排进工作流的步骤中(设置 node 为 composite_individual 或 primary_individual并将 agent_id 设置为对应的 Skill Individual 名称),作为可调用的工具。\n"
for skill in ctx.deps.available_skills:
prompt += f"- 名称: {skill['name']}\n 描述: {skill['description']}\n"
return prompt
@ -140,7 +145,8 @@ class ConsciousnessNode:
deps = ConsciousnessNodeDeps(
original_command=payload.original_command,
workflow_template=payload.workflow_template,
command="拆解原始命令变成一个工作流"
command="拆解原始命令变成一个工作流",
available_skills=payload.available_skills
)
self.logger.debug("ConsciousnessNode: 开始生成工作流 (原生重试开启)")
result = await self.agent.run(

View File

@ -44,6 +44,7 @@ class ConsciousnessNodeDeps(DepsModel):
original_command: str
workflow_template: str | None = None
command: str
available_skills: list[dict] | None = None
class ConsciousnessNodeInput(InputModel):
@ -53,6 +54,7 @@ class ConsciousnessNodeInput(InputModel):
class ForWorkflowEngineInput(ConsciousnessNodeInput):
workflow_template: str
original_command: str
available_skills: list[dict] | None = None
class ForWorkflowInput(ConsciousnessNodeInput):

View File

@ -300,9 +300,21 @@ class WorkflowRunningEngine:
workflow_template = event.context.get("workflow_template", "")
workflow_template = get_workflow_template(workflow_template)
available_skills = None
if self.global_state_machine:
try:
raw_skills = await self.global_state_machine.get_skill_list.remote()
available_skills = [
{"name": name, "description": details[0], "instructions": details[1]}
for name, details in raw_skills.items()
]
except Exception as e:
self.logger.warning(f"获取技能列表失败: {e}")
payload = ForWorkflowEngineInput(
original_command=event.message,
workflow_template=workflow_template
workflow_template=workflow_template,
available_skills=available_skills
)
result_obj = await self.consciousness_node.working.remote(payload)

View File

@ -143,6 +143,11 @@ async def test_workflow_running_engine_runner():
)
await engine.workflow_queue.put(mock_event)
# Mock the global_state_machine get_skill_list.remote method properly
mock_gsm = MagicMock()
mock_gsm.get_skill_list.remote = AsyncMock(return_value={"test_skill": ("description", "instructions")})
engine.global_state_machine = mock_gsm
with patch("pretor.core.workflow.workflow_runner.WorkflowEngine") as mock_wf_engine_cls, patch("builtins.open", new_callable=MagicMock) as mock_open:
# Instead of patching hook, we inject it directly