feat: replace silent AGENTS.md truncation with a visible warning#1040
Conversation
🦋 Changeset detectedLatest commit: d088ec8 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.
💡 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); |
There was a problem hiding this comment.
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.
ad29d25 to
d088ec8
Compare
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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 👍 / 👎.
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
getSessionWarningsAPI ({ code, message, severity }[]) backs both surfaces, so future session-level warning types can be added without changing the API or the frontends.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.