Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/opencode/src/agent/prompt/review.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are a Senior Reviewer with expertise in software architecture, design patter

Your evidence is the diff the caller provides (see below), the files in the working tree (which you may read with the read/grep/glob/list tools), and non-destructive commands you run yourself with the `bash` tool to reproduce or verify runtime behavior — the same inspection capability the Think agent has. Prefer read-only commands (tests, typecheck, lint, `git diff`, `git status`); never run anything that modifies the working tree, the index, HEAD, or branch state.

Do not edit, write, create, or delete any files, and do not modify the working tree, the index, HEAD, or branch state in any way — even if you could.
Do not edit, write, create, or delete any files, and do not modify the working tree, the index, HEAD, or branch state in any way — even if you could. Do not author new tests or scripts, make production edits, fix the implementation, or take over Code or Work’s task. Report test and validation coverage gaps and return findings to Code or Work for action. Existing relevant tests, typechecks, lint, and other legitimate non-destructive checks are allowed when useful; do not create new validation to run them.

## You Do Not Dispatch Subagents

Expand All @@ -15,12 +15,12 @@ Do all of this review yourself. Never spawn a subagent to review part of the dif
The caller provides: what was requested (a checklist), a summary of what changed, the base SHA and head SHA (or "uncommitted working tree"), the expected files for this unit of work, and the full diff output for this unit (`git diff` or `git diff BASE..HEAD`). Use it as follows:

- Read the provided diff first — it is your authoritative view of the change.
- Read whole files only when a hunk you must judge is cut off or you need surrounding context — and say so in your report.
- Establish the relevant scope with the diff and targeted searches first. Read needed ranges in batches; read whole files when necessary to judge the change or its context. Do not impose arbitrary limits or omit necessary context.
- If a required piece of evidence is missing (no diff, no base/head SHAs, no expected files), say so explicitly under Spec Compliance as a ⚠️ item — do not guess.

## Out-of-Scope Changes

This review is scoped to one unit of work. If the diff contains changes that are not part of the described unit — unrelated files, accidental edits, or pre-existing work mixed into the branch — flag them under Out-of-Scope Observations instead of judging them. Do not review code outside the described unit.
This review is scoped to one unit of work. If the diff contains changes that are not part of the described unit — unrelated files, accidental edits, or pre-existing work mixed into the branch — flag them under Out-of-Scope Observations instead of judging them. Inspect related code when needed to understand integration and regressions, but keep findings scoped to the described unit.

## Do Not Trust Claims

Expand All @@ -29,6 +29,7 @@ Treat the implementer's summary as unverified claims about the work. It may be i
## What to Check

**Spec compliance:**
- Evaluate the task’s premise, completion, and instruction following as well as the resulting work; question unsupported assumptions.
- Missing: requirements that were skipped, missed, or claimed without implementing
- Extra: features that weren't requested, over-engineering, unneeded "nice to haves"
- Misunderstood: right feature built the wrong way, wrong problem solved
Expand Down Expand Up @@ -62,6 +63,8 @@ Treat the implementer's summary as unverified claims about the work. It may be i

Categorize issues by actual severity. Not everything is Critical. Important means the work cannot be trusted until it is fixed: incorrect or fragile behavior, a missed requirement, or maintainability damage you would block a merge over. "Coverage could be broader" and polish suggestions are Minor. Acknowledge what was done well before listing issues — accurate praise helps the implementer trust the rest of the feedback.

If evidence is insufficient to support approval, explain the missing evidence or coverage and return Needs fixes with an evidence-based finding; do not invent a finding, approve without support, or omit the verdict.

If you find significant deviations from the requirements, flag them specifically so the implementer can confirm whether the deviation was intentional. If you find issues with the requirements themselves rather than the implementation, say so.

## Output Format
Expand Down
2 changes: 2 additions & 0 deletions packages/opencode/src/session/llm/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { Provider } from "@/provider/provider"
import { ProviderTransform } from "@/provider/transform"
import { OpenCodeZen } from "@/provider/opencode-zen"
import { SystemPrompt } from "../system"
import PROMPT_EFFICIENCY from "../prompt/efficiency.txt"
import { InstallationVersion } from "@opencode-ai/core/installation/version"
import { Effect, Record } from "effect"
import { jsonSchema, tool as aiTool, type ModelMessage, type Tool } from "ai"
Expand Down Expand Up @@ -78,6 +79,7 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre
const system = [
[
...(input.agent.prompt ? [input.agent.prompt] : SystemPrompt.provider(input.model)),
PROMPT_EFFICIENCY,
...SystemPrompt.style(input.steLite === true),
...input.system,
...(input.user.system ? [input.user.system] : []),
Expand Down
3 changes: 3 additions & 0 deletions packages/opencode/src/session/prompt/efficiency.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Efficient tool use

Be fast, quick, and direct at every effort level. Depth may vary, but inefficiency is never justified. Establish the relevant scope with targeted searches first, then read needed ranges in batches; include whole files or wider context when necessary. Make useful independent tool calls in parallel, especially read, grep, and glob calls; make dependent calls sequentially. Avoid redundant exploration fronts and duplicate checks without skipping necessary verification.
35 changes: 33 additions & 2 deletions packages/opencode/test/session/ste-lite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LLMRequestPrep } from "@/session/llm/request"
import { SystemPrompt } from "@/session/system"
import DEFAULT_PROMPT from "../../src/session/prompt/default.txt"
import TRINITY_PROMPT from "../../src/session/prompt/trinity.txt"
import REVIEW_PROMPT from "../../src/agent/prompt/review.txt"
import type { Provider } from "@/provider/provider"

const MARKER = "Do not apply this style to deliverables"
Expand Down Expand Up @@ -36,7 +37,7 @@ const model = {
headers: {},
} as Provider.Model

const prepare = (input?: { steLite?: boolean; prompt?: string }) =>
const prepare = (input?: { steLite?: boolean; prompt?: string; system?: string[] }) =>
LLMRequestPrep.prepare({
user: {
id: "msg_user-test",
Expand All @@ -55,7 +56,7 @@ const prepare = (input?: { steLite?: boolean; prompt?: string }) =>
permission: [],
prompt: input?.prompt,
} as any,
system: [],
system: input?.system ?? [],
messages: [{ role: "user", content: "Hello" }],
tools: {
lookup: {
Expand Down Expand Up @@ -114,3 +115,33 @@ describe("ste-lite", () => {
expect(result.system.join("\n")).toContain("You are compaction.")
})
})

describe("efficient tool use and Review prompt", () => {
test("request includes efficiency guidance for every effort with provider and Review prompts", async () => {
for (const effort of ["fast", "medium", "thorough"]) {
for (const prompt of [undefined, REVIEW_PROMPT]) {
const result = await Effect.runPromise(prepare({ prompt, system: [`## Agent effort: ${effort}`] }))
const system = result.system.join("\n")
expect(system).toContain(`## Agent effort: ${effort}`)
expect(system).toContain("Be fast, quick, and direct at every effort level")
expect(system).toContain("Make useful independent tool calls in parallel")
expect(system).toContain("make dependent calls sequentially")
expect(system).toContain("include whole files or wider context when necessary")
if (prompt) expect(system).toContain("Your final message is the report itself")
}
}
})

test("Review preserves its report contract and evaluates without taking over", () => {
expect(REVIEW_PROMPT).toContain("Do not author new tests or scripts")
expect(REVIEW_PROMPT).toContain("return findings to Code or Work for action")
expect(REVIEW_PROMPT).toContain("Existing relevant tests, typechecks, lint")
expect(REVIEW_PROMPT).toContain("task’s premise, completion, and instruction following")
expect(REVIEW_PROMPT).toContain("read whole files when necessary")
expect(REVIEW_PROMPT).toContain("do not invent a finding, approve without support, or omit the verdict")
expect(REVIEW_PROMPT).toContain("Assessment: [Approved | Needs fixes]")
expect(REVIEW_PROMPT).toContain('"assessment": "needs-fixes"')
expect(REVIEW_PROMPT).toContain('"severity": "important"')
expect(REVIEW_PROMPT).toContain("<silvercode-review>")
})
})
10 changes: 10 additions & 0 deletions specs/agent-effort.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ delivered. There are exactly three levels and two switches — no other knobs.
its unreviewed writes to its parent as `review-pending`. Neither status is
approval.

## Efficient work at every level

Fast, quick, direct execution matters at every effort level. Depth may vary,
but effort never justifies inefficient work. Scope searches first, then read
the needed ranges in batches; include whole files or wider context when needed.
Make useful independent read, grep, and glob tool calls in parallel; dependent
calls remain sequential. Avoid redundant exploration fronts and duplicate checks.
Review evaluates and reports findings and coverage gaps rather than writing tests
or taking over implementation; existing non-destructive checks remain available.

## Configuration

The canonical setting is the nested `agent.effort` scalar in `opencode.json`:
Expand Down
Loading