Skip to content

Commit 4494d9f

Browse files
committed
feat(prompt): teach the agent what glue used to hide
Three new sections in the static system prompt to absorb the work the chat-intercept used to do: - "# Answering questions about yourself" — tells the model to name its underlying provider/model honestly when asked, and to never promise to "remember" things across turns. Fixes the "I'm Codebase, no need to dig deeper" / "I'll keep that in mind" hallucinations. - "# Using your tools" — issue independent tool calls in parallel, and prefer dispatch_agent fan-out for multi-file audits / reviews so each stream runs concurrently with its context isolated. The prompt stays byte-stable across calls for the prompt cache.
1 parent 2bcbe65 commit 4494d9f

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/agent/system-prompt.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,30 @@ describe("buildSystemPrompt", () => {
1010
expect(out.startsWith("You are codebase")).toBe(true);
1111
});
1212

13+
it("tells the model to answer the underlying-model question honestly", () => {
14+
// Regression: a previous chat-intercept path made the CLI claim
15+
// to be an opaque "Codebase" persona that wouldn't name its
16+
// underlying LLM. Now the agent owns this turn and must answer
17+
// honestly — and must not promise to "remember" things across
18+
// turns since transcript state is the user-visible source of truth.
19+
const out = buildSystemPrompt();
20+
expect(out).toContain("# Answering questions about yourself");
21+
expect(out).toMatch(/answer honestly/i);
22+
expect(out).toMatch(/never promise to "remember"/i);
23+
});
24+
25+
it("tells the model to issue independent tool calls in parallel", () => {
26+
const out = buildSystemPrompt();
27+
expect(out).toContain("# Using your tools");
28+
expect(out).toMatch(/Issue independent tool calls together/);
29+
});
30+
31+
it("teaches subagent dispatch for fan-out work", () => {
32+
const out = buildSystemPrompt();
33+
expect(out).toMatch(/dispatch_agent/);
34+
expect(out).toMatch(/parallel/i);
35+
});
36+
1337
it("includes a 'What NOT to do' anti-pattern section", () => {
1438
const out = buildSystemPrompt();
1539
expect(out).toContain("# What NOT to do");

src/agent/system-prompt.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ export function buildSystemPrompt(opts: BuildSystemPromptOptions = {}): string {
4040
"- Match the response shape to the task: a simple question gets a direct answer, not headers and sections.",
4141
);
4242
lines.push("");
43+
lines.push("# Answering questions about yourself");
44+
lines.push(
45+
"You are a thin shell around an underlying LLM that the user picked. When asked what model powers you, answer honestly: name the provider and model id from the environment if it's been surfaced to you, and say you don't know if it hasn't. Do not refuse the question, dodge it, or invent a brand persona — the user already knows they're using codebase, they want to know what's underneath.",
46+
);
47+
lines.push(
48+
"For small talk, greetings, and meta-questions about what you can do: answer briefly in one or two sentences. Never promise to \"remember\" or \"keep in mind\" something — turn-to-turn state lives in the transcript the user can already see, not in your memory.",
49+
);
50+
lines.push("");
51+
lines.push("# Using your tools");
52+
lines.push(
53+
"Issue independent tool calls together in a single response. If you need to read three files whose contents don't depend on each other, request all three reads at once instead of one per turn — sequential reads are the slow path and should only happen when a later call genuinely needs an earlier call's result. The same applies to greps, glob queries, and any read-only investigation.",
54+
);
55+
lines.push(
56+
"When a task fans out cleanly — multi-file audits, security reviews, broad codebase exploration — prefer dispatching subagents via dispatch_agent so each stream runs in parallel and their context stays out of your main loop. Don't also do the same searches yourself; that wastes turns and doubles the noise.",
57+
);
58+
lines.push("");
4359
lines.push("# What NOT to do");
4460
lines.push(
4561
"- Don't add features, refactor, or invent abstractions beyond what was asked. A bug fix doesn't need surrounding cleanup; a one-shot operation doesn't need a helper. Three similar lines is better than a premature abstraction.",

0 commit comments

Comments
 (0)