makecindy / makecindy/cindy

初始 Agent 上下文被大量无关指令和跨 Profile Skill 污染

Open
#2,246 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

**提交人**: kafeifei
**客户端版本**: 0.1.38

---

## 现象

Cindy 新建 Agent 任务后,即使用户只问一个非常简单的问题,首轮请求也会注入大量与当前任务无关的上下文。

一次实际观察中,用户问题只有 19 个字符,但首轮输入已经达到 **24,212 tokens**,占 258,400 上下文窗口的 9.37%。已知常驻内容包括:

- Codex 基础指令:17,766 B
- 仓库 `AGENTS.md`:14,743 B
- Skills 清单:13,669 B,共 27 条
- Cindy 产品提示词:6,507 B
- 多 Agent 规则:2,787 B
- 推荐插件清单:1,728 B

核心问题不是“上下文窗口快满了”,而是无关指令同时生效后造成的指令冲突、注意力稀释和错误触发,最终让 Agent 表现得明显更迟钝。

另一个明确案例是 `taptap-maker`:用户已经在当前 Cindy Profile 中删除了它,但当前会话的 Skills 清单仍然出现该 Skill。排查发现,`~/.agents/skills/taptap-maker--taptap-maker` 仍指向另一个 Profile(`Cindy-dev2-pr1842`)。用户只是询问这个陌生 Skill 是什么,就触发了完整 Skill 加载和插件包排查,进一步污染了本来无关的任务上下文。

## 复现步骤

1. 在带有 `AGENTS.md` 的仓库中新建 Cindy Agent 任务。
2. 提出一个不需要检查仓库、调用插件、多 Agent 协作或加载 Skill 的简单问题。
3. 检查首轮请求的 input tokens 及上下文组成。
4. 在一个 Cindy Profile 中安装某个 Skill,在另一个 Profile 中删除它,同时保留全局 `~/.agents/skills` 中指向前者的链接。
5. 检查当前会话 Skills 清单,并提及这个本不应出现的 Skill。

## 期望行为

- 初始上下文应尽量小、去重,并严格限定在当前 Profile 和 workdir。
- 完整 Skill 指令只应在任务确实匹配时按需加载。
- 已从当前 Profile 删除,或仅安装在其他 Profile 的 Skill,不应出现在当前会话中。
- 应能查看每个上下文来源的 token/字节成本及其注入原因。
- 重叠或冲突的指令层应有明确优先级,并设置实际可执行的体积预算。

## 实际行为

- Agent 开始实际处理问题前,首轮输入已经消耗约 24k tokens。
- Host、产品、仓库、多 Agent、Skills 和插件等多层长指令同时常驻。
- 其他 Profile 的 Skill 会通过全局链接泄漏进当前会话。
- 仅仅询问这个意外出现的 Skill,就会继续加载更多无关上下文并触发排查。

## 初步定位

插件安装状态按 Profile 隔离,但 Codex 使用的 `~/.agents/skills` 投影是全局共享的。排查涉及的代码路径包括:

- `apps/desktop/src/main/cindy-brain/GhostManager.ts`
- `apps/desktop/src/main/cindy-brain/skillSlot.ts`
- `apps/desktop/src/main/maker-host/codex-global-skills.ts`

建议本 Issue 统一追踪初始上下文质量问题,包括上下文预算、按需加载、指令去重,以及 Skill 投影的 Profile 隔离。
---
**版本区域**: CN
**OS**: darwin arm64 (25.6.0)
**界面语言**: zh-CN

Contributor guide

Open the contributing guide

Research direction

Start by tracing context assembly in apps/desktop/src/main/cindy-brain/GhostManager.ts and apps/desktop/src/main/cindy-brain/skillSlot.ts, then inspect the profile projection in apps/desktop/src/main/maker-host/codex-global-skills.ts. Reproduce the cross-profile link scenario and measure the initial request contents. Done means unrelated instructions and skills are excluded from the current profile and workdir, with on-demand loading and source cost visibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, desktop
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.