From 0280b91c21efd999866ec2b330270cb5ae8400f7 Mon Sep 17 00:00:00 2001 From: Jiahe Geng <146067293+m0Nst3r873@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:48:41 +0800 Subject: [PATCH] fix(recall): stop teamai-recall subagent from recursing in cursor (#553) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The recall rule body instructs the AI to "invoke the teamai-recall subagent". In tools like Cursor that leak always-apply rules into subagent sessions, the teamai-recall subagent itself reads this and spawns another teamai-recall subagent, looping until it hangs. Add a bilingual self-exemption block at the top of both the rule body (builtin-rules.ts) and the CLAUDE.md-injected block (pull.ts): if you ARE the teamai-recall subagent, the rule does not apply — proceed directly to the search instead of invoking recall again. Co-authored-by: Claude Opus 4.8 (1M context) --- src/builtin-rules.ts | 4 ++++ src/pull.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/builtin-rules.ts b/src/builtin-rules.ts index 7713b144..6a59183e 100644 --- a/src/builtin-rules.ts +++ b/src/builtin-rules.ts @@ -122,6 +122,10 @@ export async function deployBuiltinRules( const TEAMAI_RECALL_RULE_CONTENT = `# Team Knowledge Recall (teamai) +> **Self-exemption (must read first):** If you ARE the \`teamai-recall\` subagent yourself, this rule does NOT apply to you — do not invoke \`teamai-recall\` (or any recall) again. Proceed directly to performing the knowledge search that is your task. This prevents infinite subagent recursion in tools (e.g. Cursor) whose always-apply rules leak into subagent sessions. +> +> **自豁免(务必先读):** 如果你自己就是 \`teamai-recall\` subagent,本规则对你不适用——不要再调用 \`teamai-recall\`(或任何 recall),直接执行你本职的知识检索任务。此举防止在(如 Cursor 等)会把 always-apply 规则泄漏进 subagent 会话的工具中发生无限递归。 + ## 规则:任务开始前检索团队知识库(推荐) **Before** starting a task that involves code changes, debugging, diff --git a/src/pull.ts b/src/pull.ts index fe78f22f..51d04cbc 100644 --- a/src/pull.ts +++ b/src/pull.ts @@ -1332,6 +1332,10 @@ export function compileRecallRulesBlock(): string { '', '## Team Knowledge Recall (teamai)', '', + '> **Self-exemption (must read first):** If you ARE the `teamai-recall` subagent yourself, this rule does NOT apply to you — do not invoke `teamai-recall` (or any recall) again. Proceed directly to performing the knowledge search that is your task. This prevents infinite subagent recursion in tools (e.g. Cursor) whose always-apply rules leak into subagent sessions.', + '>', + '> **自豁免(务必先读):** 如果你自己就是 `teamai-recall` subagent,本规则对你不适用——不要再调用 `teamai-recall`(或任何 recall),直接执行你本职的知识检索任务。此举防止在(如 Cursor 等)会把 always-apply 规则泄漏进 subagent 会话的工具中发生无限递归。', + '', '**Before** starting a task that involves code changes, debugging,', 'or design decisions, you **SHOULD** invoke the `teamai-recall`', 'subagent via the Agent tool with a concise natural-language',