Skip to content

[Bug]: 疑似planner输出的某个步骤没有携带“next” 跳转导致报错 #106

@JanuaryHuang

Description

@JanuaryHuang

What happened?

输入指令为
run-l -t agent_workflow -u demo_user_002 -m "为电商搜索推荐搭建一个可执行的多智能体工作流。输入是自然语言查询(示例:'运动鞋,夏天,预算100加币')。工作流目标:1) 解析查询抽取意图与约束(类目/季节/预算);2) 从本地示例商品库或在线搜索获取候选;3) 生成个性化推荐并给出理由;4) 产出一个用于前端渲染的UI布局JSON(含卡片顺序与优先级);5) 将完整结果写入 ./outputs/report.json;保存完成后立即结束工作流。"

log:

┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Role ┃ Content                                                                                                                                                        ┃
┡━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ User │ 为电商搜索推荐搭建一个可执行的多智能体工作流。输入是自然语言查询(示例:'运动鞋,夏天,预算100加币')。工作流目标:1)                                          │
│      │ 解析查询抽取意图与约束(类目/季节/预算);2) 从本地示例商品库或在线搜索获取候选;3) 生成个性化推荐并给出理由;4)                                               │
│      │ 产出一个用于前端渲染的UI布局JSON(含卡片顺序与优先级);5) 将完整结果写入 ./outputs/report.json;保存完成后立即结束工作流。                                    │
└──────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
╭──────── CoorAgent ─────────╮
│ Workflow execution started │
╰────────────────────────────╯


>>> coordinator starting execution...



<<< coordinator execution finished



>>> planner starting execution...


{
  "thought": "用户希望搭建一个电商搜索推荐的多智能体工作流,能够解析自然语言查询并生成个性化推荐。这个工作流需要多个步骤,包括意图解析、候选商品获取、推荐生成和结果输出
  "title": "电商搜索推荐多智能体工作流",
  "new_agents_needed": [],
  "steps": [
    {
      "agent_name": "EcommerceSearchRecommendationDemo",
      "title": "解析查询并提取意图与约束",
      "description": "使用EcommerceSearchRecommendationDemo智能体解析用户的自然语言查询,提取出类目、季节和预算等信息。",
      "note": "输入示例:'运动鞋,夏天,预算100加币'"
    },
    {
      "agent_name": "EcommerceSearchRecommendationDemo",
      "title": "获取候选商品",
      "description": "从本地示例商品库或在线搜索获取符合提取条件的候选商品。",
      "note": "确保候选商品符合类目、季节和预算的约束。"
    },
    {
      "agent_name": "EcommerceSearchRecommendationDemo",
      "title": "生成个性化推荐",
      "description": "基于候选商品生成个性化推荐,并给出推荐理由。",
      "note": "推荐理由应考虑用户的偏好和预算。"
    },
    {
      "agent_name": "coder",
      "title": "生成UI布局JSON",
      "description": "将推荐结果转换为前端渲染所需的UI布局JSON格式,包括卡片顺序与优先级。",
      "note": "确保JSON格式符合前端需求。"
    },
    {
      "agent_name": "reporter",
      "title": "保存结果到文件",
      "description": "将完整结果写入 ./outputs/report.json,并确保保存完成后结束工作流。",
      "note": "报告应包含所有推荐信息和生成的JSON布局。"
    }
  ]
}


<<< planner execution finished



>>> publisher starting execution...



<<< publisher execution finished



>>> agent_proxy starting execution...


{
  "category": "运动鞋",
  "season": "夏天",
  "budget": "100 加币"
}


<<< agent_proxy execution finished



>>> publisher starting execution...



<<< publisher execution finished



>>> agent_proxy starting execution...


{
  "candidates": [
    {
      "product_id": 1,
      "name": "轻便运动鞋",
      "price": 90,
      "season": "夏天",
      "category": "运动鞋",
      "description": "透气轻便,适合夏季运动。",
      "image_url": "http://example.com/product1.jpg"
    },
    {
      "product_id": 2,
      "name": "跑步鞋",
      "price": 85,
      "season": "夏天",
      "category": "运动鞋",
      "description": "专为跑步设计,舒适透气。",
      "image_url": "http://example.com/product2.jpg"
    },
    {
      "product_id": 3,
      "name": "休闲运动鞋",
      "price": 75,
      "season": "夏天",
      "category": "运动鞋",
      "description": "适合日常穿着,时尚舒适。",
      "image_url": "http://example.com/product3.jpg"
    }
  ]
}


<<< EcommerceSearchRecommendationDemo execution finished



>>> publisher starting execution...

Traceback (most recent call last):
  File "/Users/januaryh/GitHub/cooragent/src/workflow/process.py", line 196, in _process_workflow
    command = await node_func(state)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/januaryh/GitHub/cooragent/src/workflow/coor_task.py", line 92, in publisher_node
    agent = response["next"]
            ~~~~~~~~^^^^^^^^
KeyError: 'next'
⠸ Starting execution: publisher...2025-08-22 01:40:27 - src.workflow.process - ERROR - Error in Agent workflow: 'next'
╭───────── CoorAgent ──────────╮
│ Workflow execution finished! │
╰──────────────────────────────╯
CoorAgent> run-o -u demo_user_002
╭─────────────────────────────────────────────────────────────────────────────── Result ────────────────────────────────────────────────────────────────────────────────╮
│ No matching workflow found                                                                                                                                            │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
⠋ Fetched 0 workflow!
Select Command:
1 - Select workflow
2 - Exit
Enter part number: 2```

从日志结果来看,publisher_node 在读取 response["next"] 时抛了 KeyError: 'next',说明 Planner 输出的某个步骤没有携带 “next” 跳转,Publisher 没法继续路由,于是崩掉。

### Distribution version

macOS ARM 64 (Apple Silicon)

### App Version

_No response_

### What browsers are you seeing the problem on if you're using web version?

_No response_

### Are you self-hosting?

- [ ] Yes

### Self-hosting Version

_No response_

### Relevant log output

```shell

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions