Repository navigation
fix(doctor): report OpenClaw bootstrap file truncation - #1332
Conversation
- Check all default-workspace AGENTS.md content, including personal text, against OpenClaw's per-file and total bootstrap budgets. - Resolve OPENCLAW_CONFIG_PATH and state-directory config, match UTF-16 length and trailing-whitespace handling, and detect a total budget too small to load the first file. - Keep the file unchanged and explain which default-agent settings to review; document the scope and per-agent override limitation in both guide languages. - Verify 277 focused tests, TypeScript, lint and build; a real doctor CLI fixture fails the oversized-file check and passes it after shortening without automatic truncation.
|
No findings in the specified diff. The PR description documents sufficient testing, including a build and representative real-CLI verification of the oversized-file diagnostic, unchanged file contents, and successful check after shortening. Additional provider and live-agent coverage is explicitly deferred, which satisfies the review criteria. Review was read-only; no PR code was run, built, or installed. |
There was a problem hiding this comment.
This was generated by AI during triage.
@nateEc Thanks, approving. This covers the OpenClaw AGENTS.md part of the #1221 shared-budget item.
We built this head, its merge-base 6c57c3b7 and main 83f6d1db, and ran teamai doctor --json against a fixture workspace. With bootstrapMaxChars: 1000 and a 1,083-character AGENTS.md, this head reports the new check as failed ("1083 characters ... over the 1000-character bootstrap budget"); base and main have no such check. With no config, 21,083 characters fail and 19,083 pass. The new unit and e2e tests fail on base and pass here. tsc and lint pass.
Suggestions:
[P2 non-blocking]Per-agent limits produce a false failure. Withagents.defaults.bootstrapMaxChars: 20000,agents.entries.main.bootstrapMaxChars: 50000and a 30,083-character file, doctor fails and points atagents.defaults. Going by OpenClaw's source, it resolves the per-agent entry first (resolveBootstrapCharLimit), and the default agent ismain, so it would inject the file whole. The body declares per-agent limits out of scope, but the result is a failure with advice that doesn't fit. Readingagents.entries.mainfirst would fix it. We read OpenClaw's source but did not run OpenClaw.[P3 nit]openclawBootstrapBudgetnarrowsread.value.agentswithascasts.typeof/inchecks would avoid carrying over the cast pattern fromresolveOpenclawWorkspace.[P3 nit]Under 64 remaining characters the message says "over the 0-character bootstrap budget". Saying OpenClaw skips the file and namingbootstrapTotalMaxCharswould be clearer. No test catches removing the 64-character rule: replacing it still passes 6/6, because the fixture file is always longer than 63 characters.[P3 nit]The body says an unreadableopenclaw.jsonreports an unknown budget, but with a JSON5 config no OpenClaw target resolves, so the new check doesn't appear. The existing "Team rules are inlined" check reports the parse error instead. The body's "five-patch combined run" paragraph also describes runs beyond this diff.
#1331 appends to the same paragraphs in docs/guide/diagnostics.md, so whichever lands second needs a rebase there.
CI review: it reported no findings in the diff. We agree nothing blocks, but it missed the per-agent limit false failure and the unreached unreadable-JSON branch above.
- Check all default-workspace AGENTS.md content, including personal text, against OpenClaw's per-file and total bootstrap budgets. - Resolve OPENCLAW_CONFIG_PATH and state-directory config, match UTF-16 length and trailing-whitespace handling, and detect a total budget too small to load the first file. - Keep the file unchanged and explain which default-agent settings to review; document the scope and per-agent override limitation in both guide languages. - Verify 277 focused tests, TypeScript, lint and build; a real doctor CLI fixture fails the oversized-file check and passes it after shortening without automatic truncation.
Summary
Doctor could report current managed instructions while the complete
AGENTS.md, including member text, exceeded OpenClaw's bootstrap limits. Check the entire managed file againstagents.defaults.bootstrapMaxCharsandbootstrapTotalMaxCharsin the resolvedopenclaw.json, includingOPENCLAW_CONFIG_PATHoverrides.Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest runpasses completely (two unchanged local baseline failures; see below)Added/updated tests for the change
RED: a large authored prefix plus a managed block had no bootstrap-budget diagnostic.
277 focused tests pass, including exact boundaries, Unicode, total-cap exhaustion, defaults, config-path override and unmanaged files.
TypeScript, lint and build pass.
Real CLI:
doctor-openclaw-budget.test.tsrunsdoctor --json, verifies the oversized-file failure and unchanged contents, then shortens the file and verifies that check passes.Real-CLI command:
npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/doctor-openclaw-budget.test.ts.Repository-wide regression: the five-patch combined run on
origin/main6c57c3b7completed with 12,268 passed, 36 skipped, 2 failed across 503 files. Both failures are the existingsubmodule-checkoutcases for preserving empty old Claude/Codex hook files (git config --get hook.teamai-post-checkout.command). An independent pristine checkout of the same base reproduces exactly those 2 failures (24 other submodule tests pass). No new full-suite failure was introduced. The final ZCode exclusion follow-up is additionally covered by 267 uninstall/lifecycle tests and a post-uninstall pull through the real CLI.The final combined build, TypeScript and lint checks also pass. A final real-CLI run with all five patches passes 6 critical cases across all 5 affected E2E files, including the post-uninstall pull.
Related Issues
Related to #1221: OpenClaw bootstrap truncation in the default workspace.
Notes for Reviewers
Match OpenClaw's UTF-16 length, trailing-whitespace handling, positive numeric limits, 20,000/60,000 defaults and the less-than-64-character remaining-budget skip. Report an unknown budget for unreadable JSON. The diagnostic and bilingual guide identify the default-agent scope and suggest shortening the file or reviewing the limits without modifying user content. Per-agent workspace/limit overrides remain outside this default-workspace check.
Source: OpenClaw workspace/bootstrap configuration and the pinned bootstrap implementation referenced by #1221. This tests CLI diagnostics, not a running OpenClaw agent.
Local runtime tests use the Git provider and isolated filesystem fixtures; additional providers and live agent applications are deferred to CI/manual verification.