Commit f20d0d8629bf0edf451fe0be41dc6bf614aa6df7
1 parent
70a47276
fix(p2): /create 触发 orggraph-planning 用公司限定地址,并检查 HTTP 状态
真实建公司验证时发现的两个串联问题——只有起真服务才暴露得出来,
工作流的集成 agent 全程没起过服务,测试也覆盖不到。
1. 地址错误:orggraph-planning 是被 hire 进公司的,住在
data/companies/{id}/agents/ 下,寻址必须是 `{companyId}:orggraph-planning`。
原代码请求裸名 /api/agent/orggraph-planning/chat → 404 Agent not found,
agent 从未被触发,公司永远停在空壳状态。
2. 失败被静默吞掉:fetch 只在网络层出错时 reject,4xx/5xx 不会 reject,
所以原来的 .catch() 从头到尾没打印过任何东西。补 res.ok 检查 + 成功日志,
这类"地址写错"的问题以后能第一时间看见。
修复后端到端验证通过(临时公司 p2-verify,验证完已清理):
- POST /create → company.goal 落盘、orggraph-planning 被招聘且因 meta-bootstrap
被正确排除在 org graph 外
- 日志出现 "✅ 已触发 p2-verify:orggraph-planning" + ACP 会话创建
- 30 秒内 agent 产出 4 节点 5 边的图并完成 4 个角色招聘
- agent 选中 dev.json 且**扩充**出模板没有的 code-tester(goal 要求带单测),
并在规划记录里明确排除了 content.json 的歧义("Markdown/HTML 是被处理的
数据格式,不是要产出的内容作品")——模板作为"起点集合"的设计意图成立
- 产出的图实跑 validateGraph 通过四项校验
- 四个角色 config.json 均为 inheritedFrom=base(元 agent 继承路径生效),
system_agents 里 scope='company' + owner_company_id 正确
- orggraph-planning 收尾后 heartbeat.enabled=false,正确休眠
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Showing
1 changed file
with
17 additions
and
2 deletions
server/routes/company.js
| ... | ... | @@ -25,14 +25,29 @@ function triggerOrgGraphPlanning(company, tag = 'OrgGraph') { |
| 25 | 25 | const PORT = config.port || 3000; |
| 26 | 26 | const { id, name, goal, description } = company || {}; |
| 27 | 27 | |
| 28 | - fetch(`http://127.0.0.1:${PORT}/api/agent/orggraph-planning/chat`, { | |
| 28 | + // ⚠️ 必须用 `${companyId}:orggraph-planning` 这个公司限定地址。 | |
| 29 | + // orggraph-planning 是被 hire 进公司的,住在 data/companies/{id}/agents/ 下, | |
| 30 | + // 裸名 /api/agent/orggraph-planning/chat 会 404 Agent not found。 | |
| 31 | + const namespacedId = `${id}:orggraph-planning`; | |
| 32 | + | |
| 33 | + fetch(`http://127.0.0.1:${PORT}/api/agent/${encodeURIComponent(namespacedId)}/chat`, { | |
| 29 | 34 | method: 'POST', |
| 30 | 35 | headers: { 'Content-Type': 'application/json' }, |
| 31 | 36 | body: JSON.stringify({ |
| 32 | 37 | message: `公司 ${id}(${name})已创建。\n公司目标(company-goal):${goal || '(未填写)'}\n公司描述:${description || '(未填写)'}\n请按 orggraph-planning 工作流规划并建立这家公司的 workflow:读 system/org-graph-templates/ 候选骨架 + 可招角色清单,产出执行流图后调用 POST /api/company/${id}/org-graph 落库,再按拓扑序完成招聘。`, |
| 33 | 38 | conversationId: `orggraph-bootstrap-${id}-${Date.now().toString(36)}`, |
| 34 | 39 | }), |
| 35 | - }).catch(e => console.error(`[${tag}] orggraph-planning 触发失败:`, e.message)); | |
| 40 | + }) | |
| 41 | + // fetch 不会因为 4xx/5xx 而 reject,只在网络层出错时 reject。 | |
| 42 | + // 不显式检查 res.ok 的话,地址写错这类问题会被完全静默吞掉(实测踩过)。 | |
| 43 | + .then(res => { | |
| 44 | + if (!res.ok) { | |
| 45 | + console.error(`[${tag}] orggraph-planning 触发失败: HTTP ${res.status} @ ${namespacedId}`); | |
| 46 | + } else { | |
| 47 | + console.log(`[${tag}] ✅ 已触发 ${namespacedId} 规划 org graph`); | |
| 48 | + } | |
| 49 | + }) | |
| 50 | + .catch(e => console.error(`[${tag}] orggraph-planning 触发失败(网络):`, e.message)); | |
| 36 | 51 | } |
| 37 | 52 | |
| 38 | 53 | // ═══════════════════════════════════════ | ... | ... |
-
mentioned in commit cd6f294016eb6e25c437406100b4a3f00f8bac10