Skip to content

feat: replace silent AGENTS.md truncation with a visible warning#1040

Merged
RealKai42 merged 1 commit into
mainfrom
kaiyi/warsaw-v1
Jun 24, 2026
Merged

feat: replace silent AGENTS.md truncation with a visible warning#1040
RealKai42 merged 1 commit into
mainfrom
kaiyi/warsaw-v1

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Related Issue

No related issue. This addresses an internal limitation discovered during review.

Problem

Oversized AGENTS.md files were silently truncated to fit a hard 32 KB budget when injected into the system prompt. Content beyond the budget was dropped with only an HTML comment marker (invisible to users) added, so users whose AGENTS.md exceeded 32 KB would see the agent ignore their instructions with no indication of why.

What changed

  • AGENTS.md files are no longer truncated; the full content is always injected.
  • When the combined AGENTS.md size exceeds the recommended 32 KB, a warning is shown:
    • In the TUI, as a status-bar message on session start.
    • In the web UI, as a toast notification.
  • A generic getSessionWarnings API ({ code, message, severity }[]) backs both surfaces, so future session-level warning types can be added without changing the API or the frontends.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d088ec8

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

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@d088ec8
npx https://pkg.pr.new/@moonshot-ai/kimi-code@d088ec8

commit: d088ec8

@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: ad29d25cf0

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

}
if (this.session !== undefined) {
this.sessionEventHandler.startSubscription();
void this.showSessionWarnings(this.session);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Show warnings for sessions created with /new

This warning pull only runs from finishStartup, so it misses sessions started after launch via the /new command. In that path, createNewSession() creates and bootstraps the session before startSubscription() is installed, so the new agent.emitEvent({ type: 'warning', ... }) is not observed, and the path never calls showSessionWarnings; with an oversized AGENTS.md, users who start a fresh session from the TUI get no visible warning. Reuse this helper in the post-create/reload session paths as well.

Useful? React with 👍 / 👎.

Oversized AGENTS.md files are no longer silently truncated. The full
content is injected, and a warning is shown in the TUI status bar and the
web UI when the combined AGENTS.md size exceeds the recommended 32 KB.

A generic session-warnings API backs this so future warning types can be
added without changing the API surface.

@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: d088ec8850

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

export async function loadAgentsMd(kaos: Kaos, brandHome?: string): Promise<string> {
return loadAgentsMdForRoots(kaos, brandHome, [kaos.getcwd()]);
const result = await loadAgentsMdForRoots(kaos, brandHome, [kaos.getcwd()]);
return result.content;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Surface warnings for /init-generated AGENTS.md

Session.generateAgentsMd() still calls loadAgentsMd() directly after /init writes the file (packages/agent-core/src/session/index.ts:532), so returning only the content here leaves that path with no way to observe result.warning. When /init creates an AGENTS.md over 32 KB, the new full content is appended to the current session, but the startup/switch warning checks have already run and this path emits no warning event, so users keep paying the cost silently until they reload or switch sessions. Please expose the warning to this caller and emit/cache it after loading the generated file.

Useful? React with 👍 / 👎.

@RealKai42 RealKai42 merged commit 6664038 into main Jun 24, 2026
8 checks passed
@RealKai42 RealKai42 deleted the kaiyi/warsaw-v1 branch June 24, 2026 04:26
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.

1 participant