Uh oh!
There was an error while loading. Please reload this page.
feat: prepend org submodule push-to-main note to sandbox prompts - #249
Conversation
Add a hard-coded SANDBOX_PROMPT_NOTE that gets prepended to every prompt sent to the sandbox, instructing the agent to always commit and push changes in the orgs/ directory directly to main so they are preserved and shared across sessions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughIntroduces a new exported Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ❌ 1❌ Failed checks (1 warning)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/chat/tools/createPromptSandboxStreamingTool.ts`:
- Around line 5-7: The SANDBOX_PROMPT_NOTE is insufficient as enforcement;
update the sandbox execution logic in createPromptSandboxStreamingTool to add a
post-run validation/hook that programmatically inspects any git changes produced
by the tool (diff or staged/committed files), detects modifications under the
orgs/ directory, and enforces they were committed/pushed to the main branch — if
not, fail the run (throw/error) and log a clear message; implement this by
adding a postRunValidation function in createPromptSandboxStreamingTool that
checks git status/diff for "orgs/" paths, verifies git rev-parse --abbrev-ref
HEAD === "main" (or that commits affecting orgs/ target main), and either
auto-fixes by switching/committing to main or rejects the sandbox output.
- Around line 5-7: The file currently exports SANDBOX_PROMPT_NOTE alongside the
main exported function (e.g., createPromptSandboxStreamingTool); keep this file
to a single exported function by making SANDBOX_PROMPT_NOTE file-local (remove
the export) or move it into a dedicated constants module and import it; update
references in createPromptSandboxStreamingTool to use the local constant or the
imported constant accordingly so only createPromptSandboxStreamingTool remains
exported from this file.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
lib/chat/tools/__tests__/createPromptSandboxStreamingTool.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**
📒 Files selected for processing (1)
lib/chat/tools/createPromptSandboxStreamingTool.ts
| export const SANDBOX_PROMPT_NOTE = | ||
| "IMPORTANT: When you make changes to any files inside the orgs/ directory, " + | ||
| "always commit and push those changes directly to main so they are preserved and shared across sessions."; |
There was a problem hiding this comment.
Do not rely on prompt text as the only enforcement for orgs/ push-to-main policy.
This is a reliability gap: the model can ignore or deprioritize the note. For critical persistence behavior, enforce it in sandbox execution logic (e.g., post-run validation/hook) rather than instruction text alone.
Also applies to: 52-57
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/chat/tools/createPromptSandboxStreamingTool.ts` around lines 5 - 7, The
SANDBOX_PROMPT_NOTE is insufficient as enforcement; update the sandbox execution
logic in createPromptSandboxStreamingTool to add a post-run validation/hook that
programmatically inspects any git changes produced by the tool (diff or
staged/committed files), detects modifications under the orgs/ directory, and
enforces they were committed/pushed to the main branch — if not, fail the run
(throw/error) and log a clear message; implement this by adding a
postRunValidation function in createPromptSandboxStreamingTool that checks git
status/diff for "orgs/" paths, verifies git rev-parse --abbrev-ref HEAD ===
"main" (or that commits affecting orgs/ target main), and either auto-fixes by
switching/committing to main or rejects the sandbox output.
🛠️ Refactor suggestion | 🟠 Major
Keep this file to a single exported function.
SANDBOX_PROMPT_NOTE introduces a second export in a lib/**/*.ts file. Make it file-local here, or move it to a dedicated constants module and import it.
♻️ Minimal local fix
-export const SANDBOX_PROMPT_NOTE =+const SANDBOX_PROMPT_NOTE =
"IMPORTANT: When you make changes to any files inside the orgs/ directory, " +
"always commit and push those changes directly to main so they are preserved and shared across sessions.";As per coding guidelines, lib/**/*.ts: "Apply Single Responsibility Principle (SRP): one exported function per file; each file should do one thing well".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| exportconstSANDBOX_PROMPT_NOTE= | |
| "IMPORTANT: When you make changes to any files inside the orgs/ directory, "+ | |
| "always commit and push those changes directly to main so they are preserved and shared across sessions."; | |
| constSANDBOX_PROMPT_NOTE= | |
| "IMPORTANT: When you make changes to any files inside the orgs/ directory, "+ | |
| "always commit and push those changes directly to main so they are preserved and shared across sessions."; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/chat/tools/createPromptSandboxStreamingTool.ts` around lines 5 - 7, The
file currently exports SANDBOX_PROMPT_NOTE alongside the main exported function
(e.g., createPromptSandboxStreamingTool); keep this file to a single exported
function by making SANDBOX_PROMPT_NOTE file-local (remove the export) or move it
into a dedicated constants module and import it; update references in
createPromptSandboxStreamingTool to use the local constant or the imported
constant accordingly so only createPromptSandboxStreamingTool remains exported
from this file.
Uh oh!
There was an error while loading. Please reload this page.
Summary
SANDBOX_PROMPT_NOTEconstant that gets prepended to every prompt sent to the sandboxorgs/directory directly tomainso they are preserved and shared across sessionsTest plan
SANDBOX_PROMPT_NOTEis prepended to user prompts before passing topromptSandboxStreamingSANDBOX_PROMPT_NOTEis a non-empty string containing expected keywords (push, main, orgs)🤖 Generated with Claude Code
Summary by CodeRabbit