Compare commits

...

4 Commits

Author SHA1 Message Date
朝夕 0a7197295e feat: 修复了一些bug 2026-04-28 19:47:19 +08:00
朝夕 73d28793ae
Feature/skill individual consciousness 14792862208456568388 (#56)
* feat: Make skill individuals directly accessible to consciousness node

- 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: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* feat: Expose skill individuals to consciousness node & fix frontend tool parsing

- Added `available_skills` to `ConsciousnessNodeDeps` and `ForWorkflowEngineInput`.
- Updated `WorkflowRunningEngine` to retrieve all available skills from `GlobalStateMachine` and pass them into `ForWorkflowEngineInput`.
- Updated `ConsciousnessNode` to dynamically inject these skills into the prompt, enabling AI to integrate `skill_individuals` into `PretorWorkflow` steps directly.
- Fixed a frontend parsing bug in `WorkerIndividualSettings.tsx` where backend tool responses (an array of strings) were being incorrectly flattened, resulting in arrays of index numbers instead of actual tool names.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

---------

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>
2026-04-28 19:29:34 +08:00
朝夕 e03ba31f5c
Feature/skill individual consciousness 14792862208456568388 (#55)
* feat: Make skill individuals directly accessible to consciousness node

- 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: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

* feat: Expose skill individuals to consciousness node & fix frontend tool parsing

- Added `available_skills` to `ConsciousnessNodeDeps` and `ForWorkflowEngineInput`.
- Updated `WorkflowRunningEngine` to retrieve all available skills from `GlobalStateMachine` and pass them into `ForWorkflowEngineInput`.
- Updated `ConsciousnessNode` to dynamically inject these skills into the prompt, enabling AI to integrate `skill_individuals` into `PretorWorkflow` steps directly.
- Fixed a frontend parsing bug in `WorkerIndividualSettings.tsx` where backend tool responses (an array of strings) were being incorrectly flattened, resulting in arrays of index numbers instead of actual tool names.

Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>

---------

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>
2026-04-28 19:26:31 +08:00
朝夕 5eab42758b
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>
2026-04-28 17:45:15 +08:00
6 changed files with 34 additions and 4 deletions

View File

@ -45,7 +45,7 @@ export function WorkerIndividualSettings() {
setProviders(Object.values(provRes.data.provider_list || {}));
setWorkers(workRes.data.workers || []);
const allTools = toolsRes.data.tools ? Object.values(toolsRes.data.tools).flatMap(tGroup => Object.keys(tGroup as any)) : [];
const allTools = toolsRes.data.tools || [];
setAvailableTools(allTools);
setAvailableSkills(Object.keys(skillsRes.data.skills || {}));

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

@ -38,12 +38,14 @@ class WorkerCluster:
self.max_capacity = max_capacity
self._active_workers: OrderedDict[str, BaseIndividual] = OrderedDict()
self.status = "running"
self.task_queue = Queue()
self.task_queue = None
self.results_futures = {}
self.runners = []
self.num_runners = num_runners
async def start(self):
if self.task_queue is None:
self.task_queue = Queue()
self.runners = [asyncio.create_task(self._runner(i)) for i in range(self.num_runners)]
logger.info(f"WorkerCluster 已启动 {self.num_runners} 个 runner 协程。")
@ -77,6 +79,9 @@ class WorkerCluster:
async def _runner(self, runner_id: int):
while True:
try:
if self.task_queue is None:
await asyncio.sleep(0.1)
continue
task = await self.task_queue.get_async()
task_id = task.get("task_id")
agent_id = task.get("agent_id")

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