Skip to content

ref(prompt): Remove system prompt rules that duplicate tool contracts - #2315

Merged
dcramer merged 2 commits into
mainfrom
chore/trim-system-prompt
Oct 29, 2026
Merged

dcramer merged 2 commits into
mainfrom
chore/trim-system-prompt

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

This change deletes system prompt and turn context lines that repeat tool descriptions, tool contracts, or runtime gates. policies/agent-steering.md says each rule should have one home.

Removed because another surface already owns the rule

  • Tool schemas / case-sensitive names: Pi validates tool calls.
  • Workspaces: github_cloneRepository already rejects a clone that a matching Workspace covers (workspaceRequiredError), and the workspace tool descriptions already say what a Workspace is.
  • Sandbox unavailable: createSandboxUnavailableToolError already tells the model that the operation did not complete.
  • webFetch / webSearch / systemTime: their tool descriptions already cover this.
  • MCP catalog intro sentence: the searchMcpTools / callMcpTool descriptions already cover this.
  • Credential details for create and update: the credentialMode field docs already cover this. The prompt keeps the cross-tool rule "do not ask for separate confirmation".
  • Automation dispatch.outcome lines in the turn context, including the "legacy default" line: finishAutomationRun is built from the stored outcomes, and it already says whether the run posts. The runtime fallback for dispatches without outcomes does not change.
  • Removed "Actionable request: act in this turn." and "Keep tool-call explanations separate", because the next line and the output rules already say the same thing.

Moved into the owning tool description

  • searchEventTypes: use only when the user asks what events exist or the event name is unclear.
  • createEventAutomation: use only on an explicit request, and create without redundant confirmation.
  • listEventAutomations: destination scope, isCreator, trigger.available, and cross-destination update or delete. The old prompt line pointed to createdBy, but the list result does not have that field.

Moved into runtime

  • jr-rpc standalone rule: maybeExecuteJrRpcCustomCommand now rejects a jr-rpc call that comes after &&, ||, ;, |, or a newline. Before, that command went to the sandbox and failed with "command not found". A command that only mentions the name, such as grep jr-rpc, still passes through.

Merged

  • The two Slack-actions bullets about the current conversation are now one.
  • The handoff and spawnAgent line is shorter. The details stay in those tool descriptions.

Kept on purpose

  • The AGENTS.md precedence line. The wrapper in repository-instructions.ts matches Codex's exact format, and the parser depends on it.
  • "Runtime owns continuation notices" (fix(junior): Recover interrupted continuation work #388).
  • Skill policy. loadSkill does not say "load the most specific skill, do not answer from memory".
  • "Conflicting evidence". Core cannot depend on an app's SOUL.md.
  • The retry-with-another-query rule stays in tool-policy, because all run modes need it.

Checks

  • tsc --noEmit passes.
  • oxlint and prettier --check pass on the changed files.
  • These tests pass: tests/unit/prompt.test.ts, tests/unit/chat/automation-result.test.ts, tests/unit/handlers/jr-rpc-command.test.ts (one new case), tests/component/agent/sandbox.test.ts, agent-run-sandbox, agent-run-mcp-progressive-loading, agent-dispatch-work, and agent-dispatch-recovery.
  • In my sandbox, some integration tests (durable-queue, event-wake-delay, annotation-cards, event-automations) fail, mostly on timeouts. The same tests fail on the base commit, so the cause is the environment.
  • I did not run evals, because the prompt change misses the Roach recordings without ROACH_TOKEN. CI should record and run them.

via David Cramer.

--

View Junior Session [Sentry]

Move each rule to one home per policies/agent-steering.md. Tool-specific
guidance lives in the tool description, and the jr-rpc standalone rule is
now a runtime check instead of prompt prose.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 29, 2026 2:03am UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Oct 28, 2026
@sentry-evals

sentry-evals Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-guardian

Run Status Passed Failed Errored Cost Tokens Duration
Head Passed 94 0 0 $0.03 0 29.79s

Base commit 052f324 has no eval run to compare against.

finishAutomationRun is built from the stored outcomes and already says
whether the run posts, so the turn context does not need to repeat it.

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit 3e5979a into main Oct 29, 2026
46 checks passed
@dcramer
dcramer deleted the chore/trim-system-prompt branch October 29, 2026 02:22
dcramer added a commit that referenced this pull request Oct 29, 2026
Junior kept stopping to ask whether to open a PR after it finished code
work. In the most recent case, the branch was pushed and the checks
passed. Junior still held the PR because it had left out an optional
follow-up cleanup (#2315).

The guardian already treats a PR for requested code changes as ordinary.
The agent stopped itself because of two instructions:

- `github-code` said "unless the user opts out… open a PR", and then
"open a draft only when… decisions remain". Junior read an open decision
as a reason to ask, when it should have opened a draft PR. The SPEC also
still said the default was a draft.
- The core rule "Ask the user only for missing access, approval, or a
decision that blocks safe progress" lets any scope question look like a
needed approval.

Changes:

- `github-code`: code changes always end in a pushed branch and a PR,
and Junior does not ask first. The only exceptions are a user opt-out or
an investigation-only request. An open scope or follow-up question goes
in the PR body and the report. The SPEC now matches.
- Core prompt: remove "approval" from the ask-the-user rule. State that
an open scope or follow-up question does not block delivery.
- Add an eval case to `evals/coding/github.eval.ts` for the "optional
follow-up left out" scenario.

<!-- junior-request-attribution:start -->
via **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1793226615.646129 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1793226615.646129)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1793226615.646129/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>
dcramer added a commit that referenced this pull request Oct 29, 2026
The integration eval `conversation/delivery.eval.ts` > "when asked for a
top-level channel post, explain the limitation instead" fails on `main`
since #2315. This change fixes the Slack delivery rule in `prompt.ts`
that the eval checks.

**Why it fails**

#2315 merged the two Slack delivery rules into one line. The merged line
ties the explanation to tool calls ("explain the limitation instead of
calling a tool"). It also says that assistant text goes to the current
conversation. For `post this to the channel: deploy is unblocked`, a
plain reply with the text calls no tool and lands in the current
conversation, so it looked allowed. Both live samples on #2317 replied
only `deploy is unblocked`.

Before #2315, every recorded live sample passed, and each reply used the
old wording: "I can't create a new top-level channel post…".

**Is the eval correct?**

Yes. The mention is a top-level channel message. Junior can only reply
in the thread under it, so a reply with only the requested text is
wrong. The rubric follows the product rule, and the eval file has not
changed since Oct 8.

**Change**

The delivery rule stays one line, so the #2315 cleanup holds. It now:
- states the fact: a reply is not a channel post, and Junior cannot
create a new top-level channel post
- says what to do for any "post to a channel or anywhere else" request:
explain the limitation, call no tool, and do not reply with only the
requested text or present it as delivered

This PR also removes `tests/unit/prompt.test.ts`. It only checked that
the prompt output contains static strings. Evals own prompt behavior.

**Verification**

- `tsc --noEmit` passes for `@sentry/junior`.
- I could not run evals live locally (no AI Gateway or Roach
credentials). The integration eval workflow does not watch
`packages/junior/src/**`, so this PR has the `trigger-evals-integration`
label. The prompt change makes every model request new, so the whole
integration suite runs live. That gives a real comparison against the
failures on #2317.

**Open question**

Integration and behavioral evals do not run for `packages/junior/src/**`
changes, and no eval suite runs on `main`. That gap let #2315 merge
without this eval. It is out of scope here.

<!-- junior-request-attribution:start -->
via **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1793251347.186889 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1793251347.186889)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1793251347.186889/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>
thomasjiangcy added a commit that referenced this pull request Nov 3, 2026
Repo work in traces keeps taking the same detour: `searchTools("clone
repository")` → `executeTool(github_cloneRepository)` → Workspace-match
rejection → `switchWorkspace`. That is two wasted model steps on a full
context, and any sandbox work done before the switch (`loadAttachment`,
`bash`, `readFile`) runs in a default Sandbox that the switch throws
away.

Root cause: the agent cannot see which Workspace covers a repository.
#2315 removed the prompt line about Workspaces because the clone
rejection already steers to `switchWorkspace`. That made the rejected
clone the main way the agent finds a Workspace. Even before that, the
agent needed a `listWorkspaces` call to map a repo to a Workspace name.

Fix: `loadPromptTurnContext` loads the install's Workspace recipes
(`listWorkspaces(getDb())`). The bootstrap turn context renders them as
a `<workspaces>` block, next to `<available-skills>`:

```
<workspaces>
Named Sandbox recipes. After `switchWorkspace`, their repositories are already checked out.
- junior: getsentry/junior
- sentry: getsentry/getsentry, getsentry/sentry
</workspaces>
```

With no Workspaces, the block is omitted. The block lists facts only.
The clone rejection stays in place as the runtime gate.
`<context-trust>` and `policies/system-prompt.md` list the new tag as a
runtime fact.

Remaining risk:
- I did not run the behavioral or integration evals because the sandbox
has no model gateway key. Please run them before merge to confirm the
agent switches first.
- The block has no size cap. Its cost grows with the number of
Workspaces in an install.
- The list loads on each new prompt, but it renders only in the
bootstrap context. A Workspace created later in a conversation is still
found through `listWorkspaces`.

<!-- junior-request-attribution:start -->
via @thomasjiangcy.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0CCUMX7ET0%3A1793716157.810009 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0CCUMX7ET0%3A1793716157.810009)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0CCUMX7ET0%3A1793716157.810009/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Thomas Jiang <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 43e184b9 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant