Skip to content

fix(agent-core-v2): surface a warning when a skill fails to load#1987

Open
arimu1 wants to merge 2 commits into
MoonshotAI:mainfrom
arimu1:fix/1972-skill-description-length-warning
Open

fix(agent-core-v2): surface a warning when a skill fails to load#1987
arimu1 wants to merge 2 commits into
MoonshotAI:mainfrom
arimu1:fix/1972-skill-description-length-warning

Conversation

@arimu1

@arimu1 arimu1 commented Jul 21, 2026

Copy link
Copy Markdown

Related Issue

Resolve #1972

Problem

I dug into the report and the trigger turns out not to be a length limit — there is no length cap on description anywhere in the skill loader. The actual repro is a YAML gotcha: a description that contains an unquoted word: word sequence (e.g. "...Triggers on: explore the codebase...") is invalid as a plain YAML scalar, so the frontmatter fails to parse. I confirmed this directly against the parser's js-yaml call — the 453-char example from the issue throws bad indentation of a mapping entry, while a 453-char description with no colon parses fine, and the "fix" the reporter found (shortening the description) happened to also remove the colon.

Regardless of the exact trigger, the reported symptom is real: any SKILL.md whose frontmatter fails to parse is dropped from the skill list, and the only trace is a log.warn() call that goes to the internal rotating log file — nothing a user sees during a normal session.

What changed

This repo runs two engines side by side, and the fix has to land in both:

  • packages/agent-core-v2/src/app/skillCatalog/fileSkillDiscovery.ts: when a skill's frontmatter fails to parse, it's now also recorded as a skipped skill (the same mechanism already used for unsupported skill types), in addition to the existing log line.
  • packages/kap-server/src/routes/sessions.ts: GET /sessions/{id}/warnings now also includes one skill-load-failed entry per skipped skill, naming the file and the parse error. This is the path used by kimi web and by kimi -p under KIMI_CODE_EXPERIMENTAL_FLAG.
  • packages/agent-core/src/skill/scanner.ts: the byte-identical fix on the v1 engine — a SkillParseError now also records the skipped skill instead of only logging it.
  • packages/agent-core/src/session/index.ts: Session.getSessionWarnings() now includes the same skill-load-failed entries, sourced from the session's own skill registry (getSkippedByPolicy()), mirroring the kap-server route above.

An earlier version of this PR only touched the v2/kap-server side and claimed the TUI required no changes because "it already calls this endpoint." That was wrong: the interactive TUI (apps/kimi-code/src/tui/kimi-tui.ts) calls session.getSessionWarnings() on the @moonshot-ai/kimi-code-sdk client, which binds to an in-process KimiCore from @moonshot-ai/agent-core (v1), not to kap-serverkap-server/v2 is only reached by kimi web and by kimi -p under the experimental flag. Since the reporter hit this in the plain interactive TUI, only the v2 fix would never have surfaced their warning. Both engines are fixed now.

I kept this scoped to SkillParseError (invalid/missing frontmatter, missing required fields) since that's the class of failure in the issue. I left the catch-all "unexpected error" branch alone in both engines — its message is intentionally vague and not something worth surfacing as a normal warning.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill.
  • Ran gen-docs skill, or this PR needs no doc update — no new user-facing surface was added (the warning endpoint and its wire shape already existed for agents-md-oversized), so I did not touch docs/.

A SKILL.md whose frontmatter fails to parse (e.g. a description with an
unquoted colon that breaks YAML) was only logged to the internal log file
and otherwise vanished from the skill list with no visible signal. Record
these as skipped skills (same mechanism already used for unsupported skill
types) and surface them through GET /sessions/{id}/warnings, which the TUI
already shows at session start.
@changeset-bot

changeset-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 809e770

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@moonshot-ai/kimi-code Patch
@moonshot-ai/agent-core Patch
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/kap-server Patch

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95df2f4de4

ℹ️ 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".

Comment on lines +186 to +187
// Also record it as skipped (not just logged) so it surfaces as a
// session warning instead of vanishing silently.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move inline skill-discovery notes into the header

packages/agent-core-v2/AGENTS.md requires comments in this package to live only in the top-of-file /** */ block and never beside functions or statements. This new catch-block explanation violates that local review rule; please remove it or fold any necessary rationale into the module header.

Useful? React with 👍 / 👎.

The v2/kap-server fix for MoonshotAI#1972 never reached the interactive TUI: it
calls Session.getSessionWarnings() through an in-process KimiCore bound
to agent-core (v1), not kap-server. Mirror the same fix there — record a
SkillParseError as a skipped skill (byte-identical to the existing
UnsupportedSkillTypeError handling) and surface it from
getSessionWarnings() via the registry's (previously unused)
getSkippedByPolicy().
@arimu1

arimu1 commented Jul 21, 2026

Copy link
Copy Markdown
Author

Confirmed the review trace: the interactive TUI never reaches kap-server. apps/kimi-code/src/tui/kimi-tui.ts calls session.getSessionWarnings() on the @moonshot-ai/kimi-code-sdk client, whose SDKRpcClient (packages/node-sdk/src/sdk-rpc-client.ts) binds an in-process RPC to KimiCore from @moonshot-ai/agent-core — the v1 engine, not v2. kap-server/v2 is only reached by kimi web and by kimi -p under KIMI_CODE_EXPERIMENTAL_FLAG. Pushed 809e7705 to close the gap:

  • packages/agent-core/src/skill/scanner.ts: the SkillParseError branch now records a SkippedSkill (type: 'invalid-frontmatter'), same mechanism already used for UnsupportedSkillTypeError — byte-identical to the v2 fix.
  • packages/agent-core/src/session/index.ts: getSessionWarnings() now appends skill-load-failed entries from this.skills.getSkippedByPolicy(), mirroring the kap-server route logic. This registry method existed but had zero callers before this change.
  • Added regression tests: packages/agent-core/test/skill/scanner.test.ts (discovery-level, asserts onSkippedByPolicy fires) and packages/agent-core/test/harness/skill-session.test.ts (end-to-end through the same rpc.getSessionWarnings({ sessionId }) call the TUI makes).
  • Corrected the PR description, which previously claimed the TUI needed no changes — that was true only for kimi web.
  • Added @moonshot-ai/agent-core to the changeset frontmatter (now touched) and reworded the changelog entry to cover both engines.

Test results:

  • @moonshot-ai/agent-core: 3929 passed, 0 failed (full suite)
  • @moonshot-ai/agent-core-v2: 3635 passed, 0 failed (full suite, confirms the original v2 fix still holds)
  • @moonshot-ai/kap-server: 656 passed, 0 failed
  • tsc --noEmit clean on agent-core and kimi-code-sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skill silently dropped when description exceeds length limit — no warning or error

1 participant