-
Notifications
You must be signed in to change notification settings - Fork 46
Use hybrid system prompt with claude_code base and workspace context #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Changes the Claude Code runner to use a hybrid system prompt approach that combines the built-in "claude_code" prompt with workspace-specific context. **Changes:** - Modified adapter.py to use array-based system_prompt_config - First element: "claude_code" (built-in SDK prompt) - Second element: workspace context (repos, workflows, artifacts, etc.) **Benefits:** - Leverages standard Claude Code instructions and capabilities - Maintains workspace-specific context for session awareness - Better alignment with Claude Agent SDK best practices - No breaking changes to existing functionality **Documentation:** - Added comprehensive README.md for claude-code-runner component - Documented system prompt configuration approach - Included environment variables reference - Added development and testing guidelines Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
## The Problem Apple Silicon users running `make local-up` experienced: - Slow builds (15-20 minutes instead of 4-6 minutes) - Frequent crashes with: `qemu: uncaught target signal 11 (Segmentation fault)` - Next.js build failures ## Root Cause The `_build-and-load` Makefile target (used by `make local-up`) was **missing the `$(PLATFORM_FLAG)` parameter** in its build commands. **Before (BROKEN):** ```makefile _build-and-load: @$(CONTAINER_ENGINE) build -t $(BACKEND_IMAGE) components/backend @$(CONTAINER_ENGINE) build -t $(FRONTEND_IMAGE) components/frontend @$(CONTAINER_ENGINE) build -t $(OPERATOR_IMAGE) components/operator @$(CONTAINER_ENGINE) build -t $(RUNNER_IMAGE) -f components/runners/... ``` This caused: 1. Images built without explicit platform → defaulted to `amd64` 2. On Apple Silicon (arm64), amd64 images run via QEMU emulation 3. QEMU emulation is 4-6x slower and crashes during heavy builds like Next.js **Why other targets worked:** The public build targets (`build-frontend`, `build-backend`, etc.) correctly included `$(PLATFORM_FLAG)`, so running `make build-all PLATFORM=linux/arm64` worked fine. Only `make local-up` was broken. ## The Fix **After (FIXED):** ```makefile _build-and-load: @$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) -t $(BACKEND_IMAGE) components/backend @$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) -t $(FRONTEND_IMAGE) components/frontend @$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) -t $(OPERATOR_IMAGE) components/operator @$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) -t $(RUNNER_IMAGE) -f components/runners/... ``` **That's it!** Just added `$(PLATFORM_FLAG)` to 4 build commands. ## Additional Improvements While fixing the bug, we also added auto-detection so users don't have to manually set `PLATFORM`: 1. **Auto-detect architecture** (Makefile lines 18-38): - Apple Silicon → `PLATFORM=linux/arm64` (default) - Intel/AMD → `PLATFORM=linux/amd64` (default) 2. **Diagnostic tool**: ```bash make check-architecture # Shows detected vs active platform ``` 3. **Documentation**: Added troubleshooting guide in `docs/developer/local-development/kind.md` ## Impact **Before:** - Apple Silicon users: 15-20 min builds with frequent crashes - Had to manually set `PLATFORM=linux/arm64` (and even then `local-up` ignored it!) **After:** - Apple Silicon users: 4-6 min builds, no crashes - Auto-detects native architecture - Manual override still supported: `make local-up PLATFORM=linux/amd64` ## Files Changed - **Makefile** (lines 18-38, 669-675): Auto-detect + fix bug - **docs/developer/local-development/kind.md**: Troubleshooting guide - **e2e/scripts/load-images.sh**: Architecture validation ## Testing ```bash # Verify native builds make check-architecture # Should show: ✓ Using native architecture # Clean start make local-clean make local-up # Should complete in 4-6 minutes without crashes ``` Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR implements a hybrid system prompt approach for the Claude Code runner, combining the SDK's built-in Overall Assessment: ✅ Strong PR - Well-executed change with excellent documentation and useful infrastructure improvements. Issues by Severity🚫 Blocker IssuesNone - No blocking issues found. 🔴 Critical IssuesNone - No critical issues found. 🟡 Major IssuesNone - No major issues found. 🔵 Minor Issues1. Missing Test Coverage for System Prompt ChangeFile: Issue: The system prompt configuration change has no corresponding unit test to verify the hybrid array structure is correctly passed to the SDK. Current state:
Recommendation: # tests/test_system_prompt.py
def test_hybrid_system_prompt_structure(mocker):
"""Verify system prompt uses hybrid array with claude_code + workspace context."""
# Mock dependencies
adapter = ClaudeCodeRunnerAdapter(...)
# Trigger initialization that builds system_prompt_config
# ...
# Assert structure
assert isinstance(system_prompt_config, list)
assert len(system_prompt_config) == 2
assert system_prompt_config[0] == "claude_code"
assert system_prompt_config[1]["type"] == "text"
assert "Workspace Structure" in system_prompt_config[1]["text"]Priority: Medium - Tests prevent regressions 2. Version Hardcoding in Minikube ManifestFile: Issue: The Current: - name: VTEAM_VERSION
value: "v0.0.19-8-g6d9251e" # HardcodedRecommendation:
Impact: Low - This is a minikube dev manifest, not production Priority: Low - Nice-to-have cleanup Positive Highlights✅ Excellent DocumentationThe new
This sets a great standard for component documentation. ✅ Proper Architecture Auto-DetectionThe Makefile improvements (
This will save developers from cryptic QEMU segfaults. ✅ Minimal, Focused Code ChangeThe core change is just 4 lines (adapter.py:508-511): system_prompt_config = [
"claude_code",
{"type": "text", "text": workspace_prompt}
]This is the ideal PR size for a system prompt change - easy to review, low risk, clear intent. ✅ Follows Python Configuration StandardsFrom CLAUDE.md:
✅ Security-Conscious Infrastructure ChangesThe
This prevents confusing failures during CI/local testing. Recommendations1. Add Unit Test for System Prompt Structure (Priority: Medium)See Minor Issue #1 above. This ensures the hybrid prompt structure is validated. 2. Verify SDK Compatibility (Priority: High - But Likely Done)Question for reviewer/author: Has this been tested with the actual Claude Agent SDK to confirm:
If yes: Document in PR description or test plan. 3. Consider Adding E2E Test Case (Priority: Low)While not required, an E2E test could verify:
This could be a follow-up PR. 4. Update CHANGELOG or Release Notes (Priority: Medium)This is a behavior change (albeit non-breaking). Consider adding to:
Rationale from CLAUDE.md:
Architecture & Pattern Compliance✅ Follows CLAUDE.md Guidelines
✅ No Security IssuesToken Handling: No token-related code changed ✅ ✅ No Performance Concerns
Testing Checklist (From PR Description)Reviewing the test plan:
Files Changed Assessment1.
|

Summary
Changes the Claude Code runner to use a hybrid system prompt approach that combines the built-in
claude_codeprompt from the Claude Agent SDK with workspace-specific context.Changes Made
Code Changes:
adapter.py(lines 508-511) to use array-basedsystem_prompt_config"claude_code"(built-in SDK prompt with standard capabilities)Documentation:
README.mdfor the claude-code-runner componentBenefits
✅ Better SDK Alignment: Uses the official Claude Code system prompt as intended
✅ Maintains Context: Preserves workspace-specific information (repos, workflows, branches)
✅ No Breaking Changes: Existing functionality continues to work
✅ Improved Clarity: Clear separation between standard and custom instructions
Before
After
What Claude Now Receives
ambient.jsonTest Plan
Files Changed
components/runners/claude-code-runner/adapter.py(4 lines modified)components/runners/claude-code-runner/README.md(245 lines added - new file)🤖 Generated with Claude Code