Repository navigation
fix: direct skill invocation through Skill tool - #4713
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🦋 Changeset detectedLatest commit: 9745788 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
🔵 Needs a closer look
现有测试仅验证提示文本和渲染路径,尚需在曾复现问题的兼容 provider 上进行真实模型回放,确认模型会遵循新提示调用 Skill,而非直接读取技能文件。
No open issues 🎉
What changed in this PR
本 PR 统一 agent-core-v2 的模型技能加载指引,引导模型通过 Skill 工具进入既有的参数渲染、会话上下文注入和技能激活流程,避免直接读取技能文件而绕过这些处理。改动属于提示与清单契约调整,不增加运行时硬拦截。
Changes:
- 系统提示改为要求调用
Skill,模型技能清单移除文件路径。 - 工具描述明确调用顺序、直接读取的例外及参数示例,保留既有去重规则。
- 补充提示、清单和上下文渲染的回归测试,并添加 CLI patch changeset。
| File | Description |
|---|---|
packages/agent-core-v2/test/features/skill/skill.test.ts |
验证工具描述及参数、会话 ID 的渲染。 |
packages/agent-core-v2/test/features/skill/catalog/registry.test.ts |
验证模型清单不再包含技能文件路径。 |
packages/agent-core-v2/test/app/agentProfileCatalog/profile-shared.test.ts |
防止系统提示恢复直接读取技能文件的指引。 |
packages/agent-core-v2/src/features/skill/tools/skill.md |
明确工具调用要求、读取例外和参数示例。 |
packages/agent-core-v2/src/features/skill/catalog/registry.ts |
移除模型技能清单中的 Path 字段。 |
packages/agent-core-v2/src/app/agentProfileCatalog/profile-shared.ts |
将系统提示中的技能加载方式改为调用 Skill。 |
.changeset/skill-tool-invocation-contract.md |
记录面向用户的技能调用指引修复。 |
Review effort: Balanced
Restore the original BLOCKING sentence in the Skill tool description and drop the added timing clause and example. Scope the direct-read rule to the skill file itself, resolve relative paths in a loaded skill against its <skill-loaded> dir, and list the scanned skill roots once at the end of the model skill listing so skills can still be inspected or edited. Drop the tests that pinned prompt wording.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9745788896
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1 +1,3 @@ | |||
| Invoke a registered skill from the current skill listing. BLOCKING REQUIREMENT: when a skill from the listing matches the user's request, you MUST call this tool (not free-form text). Do not re-invoke a skill to repeat work already done: if a `<skill-loaded>` block for it with the same `args` is already present in the conversation, follow those instructions directly instead of calling the tool again. Do call the tool again when you need the skill with different arguments — the loaded block was expanded with the earlier `args` and will not reflect new inputs. No newline at end of file | |||
| Invoke a registered skill from the current skill listing. BLOCKING REQUIREMENT: when a skill from the listing matches the user's request, you MUST call this tool (not free-form text). Do not read a skill's file to invoke it; read the file directly only to inspect or edit the skill. Once a skill is loaded, resolve relative paths in its instructions against the `dir` attribute of its `<skill-loaded>` block. | |||
There was a problem hiding this comment.
Limit skill-directory rebasing to bundled resources
For existing skills that reference workspace files, this new instruction changes their paths incorrectly. For example, .agents/skills/translate-docs/SKILL.md:15-19 requires checking docs/zh/, docs/en/, and docs/AGENTS.md and stopping if they are missing. Resolving those against the loaded skill's dir instead checks .agents/skills/translate-docs/docs/..., causing an otherwise valid translation task to stop. Likewise, write-tui intentionally mixes workspace-relative apps/kimi-code/AGENTS.md with skill-relative ./DESIGN.md. Restrict this guidance to skill-bundled resources and preserve workspace-relative targets rather than rebasing every path in the instructions.
AGENTS.md reference: AGENTS.md:L118-L120
Useful? React with 👍 / 👎.
Requirement or Bug
使用兼容 provider 的模型在执行技能时,可能绕过
Skill工具并直接读取SKILL.md。这条路径不会执行既有的参数与 session context 渲染,导致依赖这些上下文的技能失败。本 PR 统一模型侧的技能加载指引:发现阶段只提供名称和描述,执行阶段通过
Skill进入既有渲染与激活路径。Bug Reproduction Steps
$ARGUMENTS或${KIMI_SESSION_ID},并要求模型执行该技能。Read直接读取SKILL.md,而不是调用Skill。Root Cause
旧系统提示明确要求“read the skill file for its instructions”,模型技能清单又逐项暴露
SKILL.md路径,与Skill工具描述中的调用要求形成两条相互竞争的路径。直接读取文件不会经过既有的技能渲染与激活实现,因此
$ARGUMENTS、${KIMI_SESSION_ID}和激活记录都不会按正式路径处理。内置技能的路径还是builtin://…这样的伪路径,Read打不开,照旧提示走一定失败。本 PR 修复的是造成错误选择的提示与清单契约,不增加运行时硬拦截;实际模型选择仍需通过实模型评测验证。Code Changes
核心思路是让发现与执行各自承担单一职责:发现清单只负责技能匹配,
Skill负责加载和激活。清单不再逐项给出SKILL.md路径,改为在末尾列一次技能根目录,供检查或编辑技能时定位文件;技能加载后,<skill-loaded dir="...">继续提供该技能的目录。profile-shared.ts:只替换一句系统提示,将“读取技能文件”改为“使用Skill工具”。registry.ts:模型清单不再逐项输出Path;有可调用技能时,在清单末尾用### Skill roots列出本次扫描到的技能根目录,这些目录与Read、Edit、Glob已允许访问的技能目录相同。skill.md:原有的调用要求保持不变;新增两句:不要通过读取技能文件来调用技能,直接读取只用于检查或编辑技能;技能加载后,其中的相对路径按<skill-loaded>的dir解析。Skill路径的渲染行为;按 test: remove wording-pinning tests of model-facing prose across both suites #3031 的约定,不新增锁定 prompt 原文的断言。Path,在末尾列一次根目录Path;完全不给路径Read的入口;完全不给的话,检查或编辑技能时模型找不到文件,用户级技能不在工作目录里,Glob也搜不到。Codex 的技能目录同样用### Skill roots列出根目录。Skill的调用要求阅读时先看
registry.ts和profile-shared.ts理解模型可见输入,再看skill.md和skill.test.ts理解调用契约;其余测试改动可略读。Behavior Changes and Affected Users
SkillReadPath: <SKILL.md>When to use### Skill roots列出技能根目录;技能加载后仍提供dir### Skill roots和扫描到的根目录;技能变化时的清单更新提醒也带上这几行Skill工具中的直接读取边界Read<skill-loaded>的dir解析references/、scripts/等相对路径的会话dir属性此前已经存在受影响模块与覆盖:
skills_section结构测试覆盖。registry.test.ts覆盖不再逐项输出路径、根目录列在技能之后,以及没有可调用技能时清单仍为空。skill.test.ts覆盖$ARGUMENTS和真实 session ID 经Skill路径正确渲染,且加载块带有dir属性。验证记录
pnpm -C packages/agent-core-v2 typecheck:通过。registry.test.ts中既有的makeSkill默认参数。git diff --check:通过。gen-docs已评估:公开/skill:用法不变,无需文档更新。Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.