Skip to content

fix(prompts): remove stray tab before Tool Use Guidelines heading - #1440

Open
easonLiangWorldedtech wants to merge 1 commit into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:fix/issue-1415-stray-tab-system-prompt
Open

fix(prompts): remove stray tab before Tool Use Guidelines heading#1440
easonLiangWorldedtech wants to merge 1 commit into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:fix/issue-1415-stray-tab-system-prompt

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #1415

Description

The system prompt template in src/core/prompts/system.ts indented the getToolUseGuidelinesSection() call with a leading tab, so every request sent a tab-prefixed # Tool Use Guidelines heading while every other section (e.g. markdownFormattingSection(), getCapabilitiesSection()) starts at column 0 — a meaningless whitespace token shipped to the LLM on every prompt.

  • src/core/prompts/system.ts — removes the stray tab from the template.
  • src/core/prompts/__tests__/system-prompt.spec.ts — adds a regression assertion: the prompt must contain the column-0 heading ("\n# Tool Use Guidelines\n") and must not contain the tab-prefixed variant (the old assertion only checked toContain("Tool Use Guidelines"), which passes either way).
  • Refreshed the six file snapshots that embed the generated prompt (three via -u; two more — with-computer-use-support.snap and with-different-viewport-size.snap — are orphaned by earlier refactors but still git-tracked, so they were updated by hand to keep tracked artifacts consistent).

Test Procedure

  • pnpm --filter zoo-code test core/prompts/__tests__/system-prompt.spec.ts core/prompts/__tests__/add-custom-instructions.spec.ts core/prompts/sections/__tests__/tool-use-guidelines.spec.ts → 35/35 pass against the refreshed snapshots (run without -u).
  • pnpm --dir src exec tsc --noEmit → clean.
  • pnpm --dir src exec eslint --max-warnings=0 core/prompts/system.ts core/prompts/__tests__/system-prompt.spec.ts → clean.
  • Manual: search src/core/prompts/__tests__/__snapshots__ for a tab before # Tool Use Guidelines → no matches.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): N/A — no user-visible UI change (the prompt is not rendered in the UI).
  • Documentation Impact: No user-facing documentation changes required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Visual Snapshots

N/A — no rendered UI surface.

Videos (interaction / animation only)

N/A.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The only behavioral change is the removed whitespace token in the system prompt; every snapshot diff is a single-line tab removal on the guidelines heading.

Get in Touch

easonLiangWorldedtech

…o-Code-Org#1415)

The system prompt template indented getToolUseGuidelinesSection() with a
leading tab, so every request sent a tab-prefixed "# Tool Use Guidelines"
heading instead of the column-0 heading used by every other section.
Drop the tab, pin the heading position with a regression assertion, and
refresh the six file snapshots that embedded the old prompt (two of them
orphaned by earlier refactors but still tracked).
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1a955b94-a13d-4d48-8f34-7af0652c6a2c

📥 Commits

Reviewing files that changed from the base of the PR and between b55ff87 and 956f77f.

⛔ Files ignored due to path filters (8)
  • src/core/prompts/__tests__/__snapshots__/add-custom-instructions/architect-mode-prompt.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/add-custom-instructions/ask-mode-prompt.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/add-custom-instructions/no-mcp-servers.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/system-prompt/consistent-system-prompt.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/system-prompt/with-computer-use-support.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/system-prompt/with-different-viewport-size.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap is excluded by !**/*.snap
  • src/core/prompts/__tests__/__snapshots__/system-prompt/with-undefined-mcp-hub.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: CodeQL
  • GitHub Check: platform-unit-test (ubuntu-latest)
  • GitHub Check: platform-unit-test (windows-latest)
  • GitHub Check: compile
  • GitHub Check: Build test VSIX
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: e2e-mock
🧰 Additional context used
📓 Path-based instructions (8)
Treat model, provider, MCP, path, command, and tool data as untrusted. Check approval and allowlist bypasses, injection and traversal risks, secrets/PII exposure in logs, abort and stream behavior, retries, provider compatibility, and enfor...

⚙️ CodeRabbit configuration file

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases. Check cleanup and deterministic async behavior and prefer shared typed test helpe...

⚙️ CodeRabbit configuration file

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths. Verify promises and errors are handled, existing helpers are reused, and new code introduces no `any`, unjustified dou...

⚙️ CodeRabbit configuration file

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts
Verify extension/webview contracts, cancellation and error propagation, VS Code lifecycle correctness, and behavior under retries and partial failure. Check listeners, resources, and providers are disposed without stale state or duplicate w...

⚙️ CodeRabbit configuration file

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts
Act as an adversarial second-opinion reviewer. Verify PR claims against implementation, contracts, and tests. Trace changed inputs through normal, boundary, error, cancellation, retry, and default paths and their consumers. Seek plausible c...

⚙️ CodeRabbit configuration file

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts
Add focused tests for UI binding and save behavior, persistence or normalization, and the value returned by `getStateToPostToWebview()`, including true and false/unset cases when defaults could hide omissions.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
Fix lint violations in new TypeScript code instead of suppressing them.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts
After editing a file, run ESLint with pruning and zero warnings for that relative file, and confirm its suppression count did not increase.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/core/prompts/__tests__/system-prompt.spec.ts
  • src/core/prompts/system.ts
🔇 Additional comments (2)
src/core/prompts/system.ts (1)

101-101: LGTM!

src/core/prompts/__tests__/system-prompt.spec.ts (1)

563-567: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Fixed formatting in generated system prompts so the “Tool Use Guidelines” heading appears at the correct position without unintended indentation.
    • Prevented stray leading tab characters from being included in prompts sent to the model.
  • Tests

    • Added coverage to verify the corrected heading placement and formatting.

Walkthrough

The system prompt no longer inserts a leading tab before the Tool Use Guidelines heading. Tests verify the heading starts at column 0 and does not contain the stray tab.

Changes

System prompt formatting

Layer / File(s) Summary
Remove leading tab and validate heading
src/core/prompts/system.ts, src/core/prompts/__tests__/system-prompt.spec.ts
The generated prompt emits the Tool Use Guidelines heading without indentation. Tests verify the expected newline and reject a leading tab.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 956f7

This removes an unintended tab before the Tool Use Guidelines heading and updates regression coverage and snapshots; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: edelauna, hannesrudolph, jamesrobert20, navedmerchant, taltas

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing the stray tab before the Tool Use Guidelines heading.
Description check ✅ Passed The description includes the linked issue, implementation details, test procedure, checklist, scope, and documentation impact. It is complete and relevant.
Linked Issues check ✅ Passed The changes satisfy issue #1415 by removing the leading tab from the generated system prompt and adding regression assertions for the column-0 heading and rejected tab-prefixed variant.
Out of Scope Changes check ✅ Passed The reviewed changes are limited to the prompt template and related regression tests. The described snapshot updates support the same whitespace fix and are within scope.
Regression Evidence ✅ Passed Focused coverage exists for the changed behavior. The diff changes the generatePrompt template from \\t${getToolUseGuidelinesSection()} to ${getToolUseGuidelinesSection()}. The updated `should in…
Trust And Persistence Invariants ✅ Passed PASS. The pull-request diff changes only prompt whitespace, regression assertions, and matching snapshot lines. The sole production change removes indentation before ${getToolUseGuidelinesSection()}
Full details: Regression Evidence

Explanation

Focused coverage exists for the changed behavior. The diff changes the generatePrompt template from \t${getToolUseGuidelinesSection()} to ${getToolUseGuidelinesSection()}. The updated should include native tool instructions test invokes SYSTEM_PROMPT and asserts both \n# Tool Use Guidelines\n and the absence of \t# Tool Use Guidelines. The changed prompt snapshots also record the corrected output. The interpolation is unconditional, so no affected error, negative, or unset branch is omitted. No UI change is involved.

Full details: Trust And Persistence Invariants

Explanation

PASS. The pull-request diff changes only prompt whitespace, regression assertions, and matching snapshot lines. The sole production change removes indentation before ${getToolUseGuidelinesSection()} in src/core/prompts/system.ts; it adds no input handling, execution, approval or allowlist logic, persistence operation, or resource lifecycle. The snapshot diff confirms only \t# Tool Use Guidelines to # Tool Use Guidelines, and the diff integrity check reports no errors. No changed path meets a stated failure condition.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/core/prompts/__tests__/system-prompt.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/core/prompts/system.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Review process

Thanks for contributing. This comment tracks the review sequence and the next action.

  1. Required CI checks pass.
  2. The workflow starts CodeRabbit automatically.
  3. CodeRabbit reviews and approves the latest commit.
  4. A human maintainer reviews and approves after CodeRabbit.

Current step: CodeRabbit approved the latest commit. A maintainer must now review and approve it.

@github-actions github-actions Bot added awaiting-maintainer CodeRabbit approved; waiting for a human maintainer awaiting-review PR changes are ready and waiting for maintainer re-review and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-maintainer CodeRabbit approved; waiting for a human maintainer awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Stray tab before "Tool Use Guidelines" in the system prompt

2 participants