Skip to content

Commit dbffee9

Browse files
sjarmakclaude
andcommitted
feat: V5 preamble — "not present" replaces "truncated" for MCP configs
- Add V5_PREAMBLE_TEMPLATE: opens with "Local source files are not present", mandatory 4-step workflow, concise tool selection table. 25% shorter than V4 (removes Workflows, Output Formatting, Common Mistakes, Query Patterns sections). - Switch preamble injection and system prompt from V4 to V5 for all MCP modes (sourcegraph_full, sourcegraph_base, artifact_full). - Update SG_TOOL_REFERENCE note: "not present" instead of "truncated". - Add Dockerfile.artifact_only fallback to Dockerfile.sg_only in sdlc_suite_2config.sh for tasks that lack artifact-specific images. - Keep V4_PREAMBLE_TEMPLATE as deprecated reference. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f7ca069 commit dbffee9

File tree

2 files changed

+87
-14
lines changed

2 files changed

+87
-14
lines changed

agents/claude_baseline_agent.py

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,80 @@
9898
- `deepsearch` — AI-powered deep analysis (async: returns a polling link)
9999
- `deepsearch_read` — read Deep Search results (call 60+ seconds after deepsearch)
100100
101-
Note: Sourcegraph indexes the remote repository. Local source files may be truncated — use Sourcegraph to read code.
101+
Note: Sourcegraph indexes the remote repository. Local source files are not present — use Sourcegraph to read code.
102102
"""
103103

104-
# V4 Preamble template for MCP instruction injection.
104+
# V5 Preamble template for MCP instruction injection (current official).
105+
# No truncation language — local source files simply aren't present.
106+
# 25% shorter than V4: removes Workflows, Output Formatting, Common Mistakes, Query Patterns.
107+
# {repo_scope} is replaced at runtime with the target repository filter.
108+
V5_PREAMBLE_TEMPLATE = """# IMPORTANT: Source Code Access
109+
110+
**Local source files are not present.** Your workspace does not contain source code. You **MUST** use Sourcegraph MCP tools to discover, read, and understand code before making any changes.
111+
112+
{repo_scope}
113+
114+
## Required Workflow
115+
116+
1. **Search first** — Use MCP tools to find relevant files and understand existing patterns
117+
2. **Read remotely** — Use `sg_read_file` to read full file contents from Sourcegraph
118+
3. **Edit locally** — Use Edit, Write, and Bash to create or modify files in your working directory
119+
4. **Verify locally** — Run tests with Bash to check your changes
120+
121+
## Tool Selection
122+
123+
| Goal | Tool |
124+
|------|------|
125+
| Exact symbol/string | `sg_keyword_search` |
126+
| Concepts/semantic search | `sg_nls_search` |
127+
| Trace usage/callers | `sg_find_references` |
128+
| See implementation | `sg_go_to_definition` |
129+
| Read full file | `sg_read_file` |
130+
| Browse structure | `sg_list_files` |
131+
| Find repos | `sg_list_repos` |
132+
| Search commits | `sg_commit_search` |
133+
| Track changes | `sg_diff_search` |
134+
| Compare versions | `sg_compare_revisions` |
135+
136+
**Decision logic:**
137+
1. Know the exact symbol? → `sg_keyword_search`
138+
2. Know the concept, not the name? → `sg_nls_search`
139+
3. Need definition of a symbol? → `sg_go_to_definition`
140+
4. Need all callers/references? → `sg_find_references`
141+
5. Need full file content? → `sg_read_file`
142+
143+
## Scoping (Always Do This)
144+
145+
```
146+
repo:^github.com/ORG/REPO$ # Exact repo (preferred)
147+
repo:github.com/ORG/ # All repos in org
148+
file:.*\\.ts$ # TypeScript only
149+
file:src/api/ # Specific directory
150+
```
151+
152+
Start narrow. Expand only if results are empty.
153+
154+
## Efficiency Rules
155+
156+
- Chain searches logically: search → read → references → definition
157+
- Don't re-search for the same pattern; use results from prior calls
158+
- Prefer `sg_keyword_search` over `sg_nls_search` when you have exact terms
159+
- Read 2-3 related files before synthesising, rather than one at a time
160+
- Don't read 20+ remote files without writing code — once you understand the pattern, start implementing
161+
162+
## If Stuck
163+
164+
If MCP search returns no results:
165+
1. Broaden the search query (synonyms, partial identifiers)
166+
2. Try `sg_nls_search` for semantic matching
167+
3. Use `sg_list_files` to browse the directory structure
168+
4. Use `sg_list_repos` to verify the repository name
169+
170+
---
171+
172+
"""
173+
174+
# V4 Preamble template (DEPRECATED — kept for reference).
105175
# Skill-style guidance: tool selection, scoping, context-aware behavior.
106176
# No mandatory workflow mandates — teaches effective MCP usage by example.
107177
# {repo_scope} is replaced at runtime with the target repository filter.
@@ -389,11 +459,10 @@ def create_run_agent_commands(self, instruction: str) -> list[ExecInput]:
389459
# Get repo display name for MCP prompts (centralized resolution)
390460
repo_display = self._get_repo_display()
391461

392-
# For hybrid MCP modes, prepend V4 preamble to the instruction text.
462+
# For hybrid MCP modes, prepend V5 preamble to the instruction text.
393463
if mcp_type in ("sourcegraph_full", "sourcegraph_base", "artifact_full"):
394-
# --- V4 Preamble ---
395-
# Skill-style guidance: tool selection, scoping, context-aware behavior.
396-
# No mandatory workflow mandates — teaches effective MCP usage by example.
464+
# --- V5 Preamble ---
465+
# Leads with "files not present", mandatory workflow, concise tool guidance.
397466
if repo_display != "the codebase":
398467
sg_repo_full = f"github.com/{repo_display}"
399468
repo_scope = (
@@ -408,7 +477,7 @@ def create_run_agent_commands(self, instruction: str) -> list[ExecInput]:
408477
"before searching.\n"
409478
)
410479

411-
mcp_preamble = V4_PREAMBLE_TEMPLATE.format(repo_scope=repo_scope)
480+
mcp_preamble = V5_PREAMBLE_TEMPLATE.format(repo_scope=repo_scope)
412481
instruction = mcp_preamble + instruction
413482

414483
# Artifact-full: append guidance about expressing changes as diffs
@@ -558,15 +627,13 @@ def create_run_agent_commands(self, instruction: str) -> list[ExecInput]:
558627
system_prompt_append = EVALUATION_CONTEXT_PROMPT + "\n\n---\n\n" + mcp_system_prompt
559628

560629
elif mcp_type in ("sourcegraph_full", "sourcegraph_base", "sourcegraph_isolated", "artifact_full"):
561-
# V4 system prompt: lightweight reinforcement (detailed guidance is in the instruction preamble).
630+
# V5 system prompt: reinforces that local source is absent, not truncated.
562631
if repo_display != "the codebase":
563632
repo_filter_system = f"Sourcegraph repository: github.com/{repo_display}\nFor keyword_search: repo:^github.com/{repo_display}$ YourSearchTerm"
564633
else:
565634
repo_filter_system = "Use list_repos to discover available repositories first."
566635

567-
mcp_system_prompt = f"""You have Sourcegraph MCP tools available. Use them to search, read, and navigate the codebase before making changes.
568-
569-
Local source files may be truncated or unavailable. Use Sourcegraph to read and understand code, then make edits to local files based on what you learned. Run tests locally to verify your changes.
636+
mcp_system_prompt = f"""IMPORTANT: Local source files are not present. You MUST use Sourcegraph MCP tools to discover and read code, then create or edit local files based on what you learn. Run tests locally to verify your changes.
570637
571638
{repo_filter_system}"""
572639
system_prompt_append = EVALUATION_CONTEXT_PROMPT + "\n\n---\n\n" + mcp_system_prompt

configs/sdlc_suite_2config.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,22 @@ _sdlc_run_single() {
233233

234234
elif [ "$config" = "artifact_full" ]; then
235235
local artifact="${task_path}/environment/Dockerfile.artifact_only"
236-
if [ ! -f "$artifact" ]; then
237-
echo "ERROR: Missing Dockerfile.artifact_only for $task_id at $artifact"
236+
local chosen_dockerfile=""
237+
if [ -f "$artifact" ]; then
238+
chosen_dockerfile="Dockerfile.artifact_only"
239+
elif [ -f "${task_path}/environment/Dockerfile.sg_only" ]; then
240+
echo "WARNING: No Dockerfile.artifact_only for $task_id — falling back to Dockerfile.sg_only"
241+
chosen_dockerfile="Dockerfile.sg_only"
242+
else
243+
echo "ERROR: No Dockerfile.artifact_only or Dockerfile.sg_only for $task_id"
238244
return 1
239245
fi
240246

241247
temp_task_dir="/tmp/artifact_${task_id}"
242248
rm -rf "$temp_task_dir"
243249
mkdir -p "$temp_task_dir"
244250
cp -a "${task_path}/." "${temp_task_dir}/"
245-
cp "${temp_task_dir}/environment/Dockerfile.artifact_only" "${temp_task_dir}/environment/Dockerfile"
251+
cp "${temp_task_dir}/environment/${chosen_dockerfile}" "${temp_task_dir}/environment/Dockerfile"
246252
run_task_path="$temp_task_dir"
247253
fi
248254

0 commit comments

Comments
 (0)