Feature: 引擎侧注入轮次信息,减少 agent 查轮次的工具调用 #127

Closed
opened 2026-06-06 00:29:53 +00:00 by xiaonuo · 0 comments
Owner

问题背景

在 debate workflow 中,agent 需要知道自己已经发言了几次,以便决定输出 speak 还是 final

当前的做法是在 role procedure 中写"统计你在辩论中已发言次数",但 agent 收到这条指令后需要自己摸索:

  1. 调用 uwf step listuwf thread read(经常用错 thread ID)
  2. 解析 JSON 输出,统计自己角色的出现次数

实际观察(thread 06F9MEQSK51307XCB9YDZGVA0C):

Step 角色 工具调用 用途
R1 正方 2 turns skill_view 查输出格式
R2 反方 2 turns terminal(echo) 尝试查轮次(无效)
R3 正方 1 turn 从上下文推断轮次
R4 反方 2 turns delegate_task("Count opponent speeches") 数轮次
R5 正方 7 turns terminal ×3(thread read、thread list、step list) 数轮次
R6 反方 2 turns skill_view(uwf-usage) 查文档

正方第5轮花了 7 个 turns、3 次 terminal 调用 才数清楚自己是第几次发言。

建议

方案 A:引擎侧注入轮次上下文(推荐)

在 agent 启动时,引擎注入结构化上下文:

thread_context:
  thread_id: "01HXYZ..."
  current_role: "proponent"
  my_speech_count: 2        # 当前角色已发言次数(不含本次)
  total_steps: 5
  opponent_speech_count: 2  # 对方已发言次数(可选)

Agent 直接从 prompt 读取 my_speech_count,零工具调用。

方案 B:文档最佳实践(短期 workaround)

uwf prompt workflow-authoring 中增加轮次统计最佳实践:

## 轮次统计
在 role procedure 中提供明确命令,避免 agent 自己摸索:

  uwf step list <thread-id> | grep '"role":"<your-role>"' | wc -l

我们已在 workflow 层面做了这个优化(给出具体 grep 命令),但引擎侧注入仍然是更优解。

优先级

P2 — 不影响功能正确性,但能显著减少 token 消耗和响应时间。

## 问题背景 在 debate workflow 中,agent 需要知道自己已经发言了几次,以便决定输出 `speak` 还是 `final`。 当前的做法是在 role procedure 中写"统计你在辩论中已发言次数",但 agent 收到这条指令后需要自己摸索: 1. 调用 `uwf step list` 或 `uwf thread read`(经常用错 thread ID) 2. 解析 JSON 输出,统计自己角色的出现次数 **实际观察(thread `06F9MEQSK51307XCB9YDZGVA0C`):** | Step | 角色 | 工具调用 | 用途 | |------|------|---------|------| | R1 正方 | 2 turns | `skill_view` | 查输出格式 | | R2 反方 | 2 turns | `terminal(echo)` | 尝试查轮次(无效) | | R3 正方 | 1 turn | 无 | 从上下文推断轮次 | | R4 反方 | 2 turns | `delegate_task("Count opponent speeches")` | 数轮次 | | R5 正方 | 7 turns | `terminal` ×3(thread read、thread list、step list) | 数轮次 | | R6 反方 | 2 turns | `skill_view(uwf-usage)` | 查文档 | 正方第5轮花了 **7 个 turns、3 次 terminal 调用** 才数清楚自己是第几次发言。 ## 建议 ### 方案 A:引擎侧注入轮次上下文(推荐) 在 agent 启动时,引擎注入结构化上下文: ```yaml thread_context: thread_id: "01HXYZ..." current_role: "proponent" my_speech_count: 2 # 当前角色已发言次数(不含本次) total_steps: 5 opponent_speech_count: 2 # 对方已发言次数(可选) ``` Agent 直接从 prompt 读取 `my_speech_count`,零工具调用。 ### 方案 B:文档最佳实践(短期 workaround) 在 `uwf prompt workflow-authoring` 中增加轮次统计最佳实践: ```markdown ## 轮次统计 在 role procedure 中提供明确命令,避免 agent 自己摸索: uwf step list <thread-id> | grep '"role":"<your-role>"' | wc -l ``` 我们已在 workflow 层面做了这个优化(给出具体 grep 命令),但引擎侧注入仍然是更优解。 ## 优先级 P2 — 不影响功能正确性,但能显著减少 token 消耗和响应时间。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#127