Skip to content

fix(doctor): report OpenClaw bootstrap file truncation - #1332

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-openclaw-bootstrap-budget
Oct 23, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-openclaw-bootstrap-budget

Conversation

@nateEc

@nateEc nateEc commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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 against agents.defaults.bootstrapMaxChars and bootstrapTotalMaxChars in the resolved openclaw.json, including OPENCLAW_CONFIG_PATH overrides.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes

  • npm run lint passes

  • npx vitest run passes 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.ts runs doctor --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/main 6c57c3b7 completed with 12,268 passed, 36 skipped, 2 failed across 503 files. Both failures are the existing submodule-checkout cases 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.

- 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.
@github-actions

Copy link
Copy Markdown

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.

@SaulMoro SaulMoro left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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. With agents.defaults.bootstrapMaxChars: 20000, agents.entries.main.bootstrapMaxChars: 50000 and a 30,083-character file, doctor fails and points at agents.defaults. Going by OpenClaw's source, it resolves the per-agent entry first (resolveBootstrapCharLimit), and the default agent is main, 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. Reading agents.entries.main first would fix it. We read OpenClaw's source but did not run OpenClaw.
  • [P3 nit] openclawBootstrapBudget narrows read.value.agents with as casts. typeof/in checks would avoid carrying over the cast pattern from resolveOpenclawWorkspace.
  • [P3 nit] Under 64 remaining characters the message says "over the 0-character bootstrap budget". Saying OpenClaw skips the file and naming bootstrapTotalMaxChars would 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 unreadable openclaw.json reports 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.

@SaulMoro
SaulMoro merged commit d019b5b into Tencent:main Oct 23, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
- 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.
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.

3 participants