From d9a785d49d1f9547a7e768a009c1e0dd82dd243a Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 9 Mar 2026 05:57:38 -0700 Subject: [PATCH] fix(iagent): make dingtalk/feishu endpoint separation explicit in system prompt Add CRITICAL note and clear IF/ELSE branching so Claude never calls dingtalk endpoints for feishu binding or vice versa. Co-Authored-By: Claude Sonnet 4.6 --- .../claude-code-cli/system-prompt-builder.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts b/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts index 6be3b40..836378b 100644 --- a/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts +++ b/packages/services/agent-service/src/infrastructure/engines/claude-code-cli/system-prompt-builder.ts @@ -79,22 +79,25 @@ export class SystemPromptBuilder { ' wget -q -O- --post-data=\'{"name":"","userId":"","usePool":true}\' --header="Content-Type: application/json" http://localhost:3002/api/v1/agent/instances\n' + ' Parse JSON to get "id" (instanceId) and "name".\n' + ' Say: "好的,小龙虾「」已经创建好了!接下来把它和你的即时通讯工具绑定,方便直接对话。你想绑定钉钉、飞书,还是都绑定?"\n\n' + - ' Step 3 — Channel binding (based on user choice):\n\n' + - ' [DingTalk / both]\n' + - `${dingtalkOauthStep}\n\n` + - ' DingTalk confirm:\n' + + ' Step 3 — Channel binding (based on user choice; NEVER mix up endpoints):\n\n' + + ' IF user chose 钉钉 (DingTalk) OR both:\n' + + ' *** Use ONLY dingtalk endpoints — /channels/dingtalk/... ***\n' + + `${dingtalkOauthStep}\n` + + ' DingTalk confirm (ONLY dingtalk endpoint):\n' + ' wget -q -O- http://localhost:3002/api/v1/agent/channels/dingtalk/status/\n' + ' If { "bound": true }: "钉钉绑定成功!"\n' + ' If still false: "授权还没完成,请确认是否点击了钉钉里的授权按钮。"\n\n' + - ' [Feishu / both]\n' + - ' Call the bind-code API to get a 6-character code:\n' + + ' IF user chose 飞书 (Feishu) OR both:\n' + + ' *** Use ONLY feishu endpoints — /channels/feishu/... ***\n' + + ' Get bind code (ONLY feishu endpoint):\n' + ' wget -q -O- --post-data="" http://localhost:3002/api/v1/agent/channels/feishu/bind/\n' + ' Parse JSON: { "code": "", "expiresAt": }\n' + ' Say: "飞书绑定验证码是「」,有效15分钟。请打开飞书,找到 iAgent 机器人,把这个验证码发给它,就完成绑定啦。"\n' + - ' Then poll every 5s (up to 3 min) to confirm:\n' + + ' Poll to confirm (ONLY feishu endpoint, every 5s up to 3 min):\n' + ' wget -q -O- http://localhost:3002/api/v1/agent/channels/feishu/status/\n' + ' If { "bound": true }: "太好了!飞书绑定成功了!"\n\n' + - ' [skip / neither]: "好的,之后想绑定随时可以在 IT0 App 里操作。"\n\n' + + ' IF user chose skip / neither: "好的,之后想绑定随时可以在 IT0 App 里操作。"\n\n' + + ' CRITICAL: dingtalk endpoints (/channels/dingtalk/) and feishu endpoints (/channels/feishu/) are completely separate. Never call a dingtalk endpoint for feishu or vice versa.\n\n' + ' Check/unbind:\n' + ' DingTalk status: wget -q -O- http://localhost:3002/api/v1/agent/channels/dingtalk/status/\n' + ' DingTalk unbind: wget -q -O- --post-data="" http://localhost:3002/api/v1/agent/channels/dingtalk/unbind/\n' +