Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
968de55
feat(prompt-preset): agent-first Grok 4.5 worker profiles
islee23520 Aug 1, 2026
0b9d69f
ci: retrigger after unrelated packages/agent flake
islee23520 Aug 1, 2026
be5978f
docs(prompt-preset): resolve Grok Oracle changelog contradiction
islee23520 Aug 1, 2026
7937eff
fix(prompt-preset): ban nested worker spawns in Implementer briefs
islee23520 Aug 1, 2026
4ec38cb
fix(prompt-preset): enforce child worker system roles
islee23520 Aug 1, 2026
71b30d2
merge: sync main into Grok worker profiles
islee23520 Aug 1, 2026
fde7263
ci: retry flaky MCP prompt registration test
islee23520 Aug 1, 2026
561d39e
fix(prompt-preset): address final Grok worker review
islee23520 Aug 1, 2026
e87155a
fix(prompt-preset): harden worker rule contracts
islee23520 Aug 1, 2026
c01435d
fix(prompt-preset): preserve prompt metadata semantics
islee23520 Aug 1, 2026
dc177ae
fix(prompt-preset): close final worker contract gaps
islee23520 Aug 1, 2026
7d251c5
refactor(prompt-preset): share prompt metadata helpers
islee23520 Aug 1, 2026
8754a66
docs(prompt-preset): clarify worker isolation boundary
islee23520 Aug 1, 2026
dc0aa9e
ci: retry unrelated MCP prompt registration flake
islee23520 Aug 1, 2026
63860c5
fix(prompt-preset): align worker and append invariants
islee23520 Aug 1, 2026
a2739f7
fix(prompt-preset): bound worker returns and source metadata
islee23520 Aug 1, 2026
fd67d99
ci: retry unrelated MCP catalog cache flake
islee23520 Aug 1, 2026
b085061
fix(prompt-preset): append cleanly to empty prompts
islee23520 Aug 1, 2026
3d88a60
ci: retry persistent MCP prompt registration flake
islee23520 Aug 1, 2026
c816650
docs(prompt-preset): align final worker evidence contract
islee23520 Aug 1, 2026
d8e9854
fix(prompt-preset): align empty prompt append paths
islee23520 Aug 1, 2026
2552ca7
test(prompt-preset): distinguish event prompt precedence
islee23520 Aug 1, 2026
966eb1f
refactor(prompt-preset): unify system prompt composition
islee23520 Aug 1, 2026
f69cb4b
fix(prompt-preset): close 4 security review blockers
islee23520 Aug 2, 2026
f1221dd
fix(prompt-preset): close eleven follow-up review findings
islee23520 Aug 2, 2026
f91f552
fix(agent-session): clear a stale prompt override on a base reset
islee23520 Aug 2, 2026
2997f16
merge: sync main into Grok worker profiles
islee23520 Aug 3, 2026
9a69949
merge: sync latest main into Grok worker profiles
islee23520 Aug 3, 2026
b11e8a6
style(compaction): format merged idle retry call
islee23520 Aug 3, 2026
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
23 changes: 23 additions & 0 deletions packages/coding-agent/src/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1272,3 +1272,26 @@ The retry budget, abortable retry sleep, provider continuation, and active model
### Why extension system couldn't handle this

The instrumented transitions (`_emit`, queue internals, `RequiredCompactionError` admission, the TUI compaction queue, clipboard catch) are private `AgentSession`/`InteractiveMode` state with no extension-visible hook carrying the needed fields; field debugging of "stuck forever" sessions (Discord report 2026-07-30) requires a single post-hoc timeline in the logs directory.
## Explicit CLI system prompts survive model presets (2026-08-01)

### What changed

- `main.ts` now forwards parsed `--system-prompt` and repeated `--append-system-prompt` values into both normal and list-models resource-loader construction.
- `AgentSession` exposes those static replacement/append inputs in `systemPromptOptions` so per-model prompt presets can respect explicit caller intent.
- The prompt-preset builtin skips replacement when an explicit custom prompt exists and preserves explicit suffixes after a selected preset.
- Explicit empty prompt input now counts as a supplied replacement; this is an intentional bug fix to the existing replacement contract.
- Regression coverage locks replacement precedence, append placement, and fast-path option forwarding.

### Why

- The CLI documented and parsed these options, but did not pass them to the loader. Even if supplied through SDK construction, the per-turn prompt-preset hook replaced the explicit prompt.
- Grok worker profiles require role doctrine at system priority; user-message briefs cannot override a contradictory model preset.

### Why extension system couldn't handle this alone

- The preset can decide whether to yield, but only the host can forward CLI inputs and expose their provenance in per-turn prompt metadata.

### Expected merge conflict zones

- MEDIUM: `main.ts` resource-loader option construction and `core/agent-session.ts` system prompt rebuild metadata.
- LOW: prompt-preset `before_agent_start` precedence tests.
11 changes: 7 additions & 4 deletions packages/coding-agent/src/core/agent-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ import { SessionWorkBarrier } from "./session-work-barrier.ts";
import type { SettingsManager } from "./settings-manager.ts";
import type { SlashCommandInfo } from "./slash-commands.ts";
import { createSyntheticSourceInfo, type SourceInfo } from "./source-info.ts";
import { appendToSystemPrompt, type BuildSystemPromptOptions } from "./system-prompt.ts";
import { getSupportedThinkingLevels, supportsMax, supportsXhigh } from "./thinking-levels.ts";
import { resetTimings, time } from "./timings.ts";
import { type BashOperations, createLocalBashOperations } from "./tools/bash.ts";
Expand Down Expand Up @@ -668,7 +669,8 @@ export class AgentSession {
private _currentServiceTier: ServiceTier | undefined = undefined;
private _sessionFastMode = false;
private readonly _shownHighReasoningWarningKeys = new Set<string>();
private _baseSystemPromptOptions!: BuildDynamicSystemPromptOptions;
private _baseSystemPromptOptions!: BuildDynamicSystemPromptOptions &
Pick<BuildSystemPromptOptions, "customPrompt" | "appendSystemPrompt">;
private _systemPromptOverride?: string;

constructor(config: AgentSessionConfig) {
Expand Down Expand Up @@ -2270,11 +2272,12 @@ export class AgentSession {
selectedTools: validToolNames,
toolSnippets,
promptGuidelines,
customPrompt: loaderSystemPrompt,
appendSystemPrompt: loaderAppendSystemPrompt.join("\n\n") || undefined,
};
const basePrompt = loaderSystemPrompt ?? buildDynamicSystemPrompt(this._baseSystemPromptOptions);
return loaderAppendSystemPrompt.length > 0
? `${basePrompt}\n\n${loaderAppendSystemPrompt.join("\n\n")}`
: basePrompt;
const append = loaderAppendSystemPrompt.join("\n\n");
return appendToSystemPrompt(basePrompt, append || undefined);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,29 +264,32 @@

## Grok 4.5 preset (unreleased — 2026-07-17)

Grok 4.5 has **not** been formally merged. Do not invent `v1`/`v2`/… edition labels for unreleased retunes — keep a single current section for this feature until it lands.

### What changed (current branch state)
- `grok-4.5.ts` (2026-07-28, diet): CEO core compressed from 4606 to 3832 template characters (~17% cut) with zero behavior removal, grounded in xAI Grok 4.5 guidance (docs.x.ai/developers/grok-4-5; the grok-code prompt-engineering guide): Grok 4.5 follows terse, structured instructions without repeated emphasis and is trained for tool-loop reliability, so triplicated rules were merged into single homes. Specifically: the audit rules (Role bullet + Operating Loop step 4 + Verification section) collapsed into one **Audit** bullet; the human-surface/report contract (intro + Role bullet + Output) into intro + **Output**; Intent-gate/ask-one-question (Intent Gate + Loop step 1) into **Intent Gate**; plan/todo (Loop step 2) and parallel delegation (Loop step 3) into the **Delegate** bullet; Oracle review (Role bullet + Loop step 5) into the **Consult Oracle** bullet. The `## Operating Loop` and `## Verification` headings are gone; every unique rule they carried survives. All preset-test anchors unchanged and green.
- `grok-4.5.ts`: rewritten as a full-core preset via the `corePrompt` override (same shape as `gpt-5.5.ts` / `gpt-5.6.ts`). The role is now **CEO / orchestrator**, not a sibling tuningSection: Grok 4.5 acts as the single human-facing surface, delegates implementation work to background worker subprocesses spawned via `bash` as `senpi --print -p "..." --model <worker>` invocations (background `&` for parallel, output to temp files, `read` to collect), framed against GPT-5.6 prompting doctrine (implement-don't-propose, Manual QA Gate, binding stop contract). It consults a separate `senpi --print` review invocation before deploying non-trivial changes (the Oracle pattern), audits worker evidence rather than relaying self-report, and reports synthesized outcomes to the user. Trivial one-line fixes stay direct.
- senpi does NOT expose a `task` / `subagent` / `spawn` tool to the model - the built-in tool surface is bash/edit/read/write/grep/ls/find. So the CEO delegates through the concrete primitive it has (`bash` spawning `senpi --print` subprocesses), mirroring the gpt-5.6.ts rule of never naming tools that do not exist here. An earlier draft of this preset referenced a `task` tool with `category: "deep"` / `"ultrabrain"` values; that was a defect (those are the *orchestrator-side* task tool's categories, not anything the senpi agent exposes to Grok), and the regression test now explicitly pins that those names do not appear in the preset.
- Reuses `buildTestDisciplineSection()` and `buildFileOperationsTuning()` so shared rules stay single-sourced. Dynamic pieces (tool section, context files, skills, date, cwd) still come from `buildDynamicSystemPrompt`.
- Prior tuningSection content (act-once-context-sufficient, claim-auditing, no-promise-endings, context-limit continuation) was superseded by the CEO core, which subsumes those rules into the CEO's audit + reporting duties and the binding Stop Goal. The Mario benchmark rationale is preserved below for history.
- Benchmark evidence from the prior tuningSection version is under `local-ignore/qa-evidence/20260717-grok45-mario-benchmark/`.
- `presets.ts`: `hasGrok45Signal` / `isGrok45Model` unchanged (match any Grok 4.5 id shape without catching `grok-4.3` / `grok-4.20-*` / `grok-3`).
- `settings.ts`: `"grok-4.5"` joins `PromptPresetName` / `VALID_PRESETS` (unchanged).
- `test/suite/prompt-presets-grok-4-5.test.ts`: id resolution, negative neighbors, settings force, and catalog coverage unchanged. The old tuning-string regex pins and the 900–1800 character tuning-size guard were replaced with CEO-signal assertions (acting as the CEO and orchestrator; delegate implementation to background workers via `bash`; `senpi --print`; GPT-5.6 prompting doctrine; implement-don't-propose; Manual QA Gate; consult Oracle before deploying; you are the human surface; Stop Goal; STOPPING IS MANDATORY AND IMMEDIATE; `apply_patch` and `### Test Discipline` present; routing-line preserved). Also pins that the preset does NOT name a nonexistent `task`/`category`/`run_in_background` tool.
### Agent-first Implementer/Oracle profiles (2026-08-01)

### Why
- The CEO role is not a small addendum on top of the default identity — it is a different operating posture (orchestrator + human surface, not implementer), which the `tuningSection` shape cannot express. The `corePrompt` override is the documented path for full-role rewrites (per `AGENTS.md` and the gpt-5.5/5.6 precedent). The Mario benchmark established that evidence-grounded continuation and claim-auditing are the right Grok 4.5 execution discipline; the CEO core subsumes those into the CEO's audit + reporting duties and the Stop Goal rather than duplicating them.
- Delegation framing against GPT-5.6 doctrine is chosen because the gpt-5.6 preset already encodes that doctrine for the implementation-worker role; the CEO points its worker children at the same doctrine so worker behavior matches what gpt-5.6 would do in-session.
#### What changed
- `grok-4.5.ts` Role section: dropped the sole `--model gpt-5.6*` implementer path and the "gpt-5.6 prompting guide loads doctrine automatically" coupling.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new Agent-first changelog section contradicts the retained '### What changed (current branch state)' block in the same changes.md (it still says workers are framed against GPT-5.6 prompting doctrine, Oracle runs 'before deploying', and parallel & spawn is fine), and the retained note that the test pins 'GPT-5.6 prompting doctrine' no longer matches the test (which asserts not.toMatch(/gpt-5.6 prompting guide/i)). Since this section is labeled as the current branch state, the stale/contradictory text will mislead future readers; consider updating or retiring it now that the agent-first retune lands.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/coding-agent/src/core/extensions/builtin/prompt-preset/changes.md, line 270:

<comment>The new Agent-first changelog section contradicts the retained '### What changed (current branch state)' block in the same changes.md (it still says workers are framed against GPT-5.6 prompting doctrine, Oracle runs 'before deploying', and parallel `&` spawn is fine), and the retained note that the test pins 'GPT-5.6 prompting doctrine' no longer matches the test (which asserts not.toMatch(/gpt-5\.6 prompting guide/i)). Since this section is labeled as the current branch state, the stale/contradictory text will mislead future readers; consider updating or retiring it now that the agent-first retune lands.</comment>

<file context>
@@ -264,6 +264,28 @@
+### Agent-first Implementer/Oracle profiles (2026-08-01)
+
+#### What changed
+- `grok-4.5.ts` Role section: dropped the sole `--model gpt-5.6*` implementer path and the "gpt-5.6 prompting guide loads doctrine automatically" coupling.
+- Workers are **invocation profiles** expressed in the brief, not tools: **Implementer** (workspace-writing executor) and **Oracle** (read-only analysis/high-risk review). Critic/Planner/Explorer are not named agents — planning/recon stay with the CEO unless hard analysis needs Oracle.
+- Implementer doctrine is model-independent and must live in every brief: implement rather than propose; inspect/edit/scoped tests/Manual QA; preserve unrelated work; stop after three different failed approaches; return changed files, commands/results, blockers.
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed / already superseded in be5978f and re-checked in 7937eff.

There is no remaining present-tense ### What changed (current branch state) block. Historical notes are labeled superseded by the 2026-08-01 agent-first retune, and the current subsection is the source of truth for Oracle wording and model-independent doctrine.

- Workers are **invocation profiles** supplied through each child's explicit `--system-prompt`, not tools or user-message-only personas: **Implementer** (workspace-writing executor) and **Oracle** (read-only analysis/high-risk review). Critic/Planner/Explorer remain CEO responsibilities.
- Implementer/Oracle doctrine is model-independent at system priority: both prohibit nested workers; Implementer owns edits/tests/Manual QA, while Oracle has a read-only tool allowlist and no shell.
- Spawn remains `bash` + `senpi --print`, now with private `umask 077` / `mktemp -d` transport, cleanup traps, separate output/status files, `env -i` environment minimization, ephemeral `--no-session`, disabled discovered/user extensions plus skills/context/templates/nested-AGENTS/fallback, and per-role `--tools` allowlists. Builtin host controls may remain, but explicit replacement prompt precedence is proven through the actual resource-loader → session → preset hook path and provider-visible faux requests; role-system precedence and tool allowlists are the worker boundary.
- CLI `--system-prompt` / `--append-system-prompt` values are forwarded in this PR through `main.ts` into the resource loader and `agent-session.ts`. An explicit replacement wins over model presets; explicit appends remain after the selected preset. Provider-visible coverage lives in `prompt-presets-explicit-system-prompt.test.ts`, with CLI forwarding covered by `list-models-fast-path.test.ts`. This closes the recursive-Grok child path discovered during review.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The PR description states this is a prompt-only change with no CLI/tooling, but the new changes.md section claims CLI --system-prompt/--append-system-prompt forwarding "is forwarded in this PR through main.ts into the resource loader and agent-session.ts". These contradict each other on whether host code changed here. Reconcile the description and the doc so future fork merges know whether main.ts/agent-session.ts forwarding landed in this PR or is pre-existing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/coding-agent/src/core/extensions/builtin/prompt-preset/changes.md, line 274:

<comment>The PR description states this is a prompt-only change with no CLI/tooling, but the new changes.md section claims CLI `--system-prompt`/`--append-system-prompt` forwarding "is forwarded in this PR through main.ts into the resource loader and agent-session.ts". These contradict each other on whether host code changed here. Reconcile the description and the doc so future fork merges know whether main.ts/agent-session.ts forwarding landed in this PR or is pre-existing.</comment>

<file context>
@@ -264,29 +264,32 @@
+- Workers are **invocation profiles** supplied through each child's explicit `--system-prompt`, not tools or user-message-only personas: **Implementer** (workspace-writing executor) and **Oracle** (read-only analysis/high-risk review). Critic/Planner/Explorer remain CEO responsibilities.
+- Implementer/Oracle doctrine is model-independent at system priority: both prohibit nested workers; Implementer owns edits/tests/Manual QA, while Oracle has a read-only tool allowlist and no shell.
+- Spawn remains `bash` + `senpi --print`, now with private `umask 077` / `mktemp -d` transport, cleanup traps, separate output/status files, `env -i` environment minimization, ephemeral `--no-session`, disabled discovered/user extensions plus skills/context/templates/nested-AGENTS/fallback, and per-role `--tools` allowlists. Builtin host controls may remain, but explicit replacement prompt precedence is proven through the actual resource-loader → session → preset hook path and provider-visible faux requests; role-system precedence and tool allowlists are the worker boundary.
+- CLI `--system-prompt` / `--append-system-prompt` values are forwarded in this PR through `main.ts` into the resource loader and `agent-session.ts`. An explicit replacement wins over model presets; explicit appends remain after the selected preset. Provider-visible coverage lives in `prompt-presets-explicit-system-prompt.test.ts`, with CLI forwarding covered by `list-models-fast-path.test.ts`. This closes the recursive-Grok child path discovered during review.
+- Oracle wording is high-risk final review / hard debug — not "before deploying". One orchestration level; workers must not re-delegate.
+- Brief fields: ROLE, GOAL, SCOPE, CONSTRAINTS, DONE WHEN, RETURN.
</file context>

- Oracle wording is high-risk final review / hard debug — not "before deploying". One orchestration level; workers must not re-delegate.
- Brief fields: ROLE, GOAL, SCOPE, CONSTRAINTS, DONE WHEN, RETURN.
- Tests pin effective prompt precedence, CLI option forwarding, worker spawn controls, id resolution, settings force, catalog sweep, and no fake task-tool API.

### Why extension system couldn't handle this differently
- Preset selection and family tuning are owned by this builtin; no core prompt code changed.
#### Why
- User direction: prefer specifying worker **roles** over locking every implementation child to GPT. Model presets must not be the only carrier of execution doctrine under senpi's no-task-tool harness.
- Oracle/Momus/Metis review of the multi-agent plan: five named agents overbuilt; 2 profiles max; doctrine cannot depend on gpt-5.6 preset. Follow-up code review proved user-message briefs alone could not override child model presets, requiring the minimal CLI prompt-precedence support above.

### Expected merge conflict zones on next upstream sync
- LOW: `presets.ts` Grok matcher / `settings.ts` union if upstream adds its own Grok preset.
- LOW: `grok-4.5.ts` wording and Grok test phrase pins.
#### Why extension system couldn't handle this differently
- The preset owns role selection, but explicit CLI prompt values were not forwarded and a per-turn preset otherwise replaced the loader prompt. The host must preserve the documented explicit prompt precedence before the preset can safely create role-specific child sessions.

#### Expected merge conflict zones on next upstream sync
- MEDIUM: `main.ts` resource-loader option forwarding and `agent-session.ts` prompt metadata.
- LOW: prompt-preset precedence, Grok Role wording, and focused tests.

Grok 4.5 has **not** been formally merged. Do not invent `v1`/`v2`/… edition labels for unreleased retunes — keep a single current section for this feature until it lands. The **Agent-first Implementer/Oracle profiles (2026-08-01)** subsection above is the current design. Historical notes below are retained only for provenance and are **superseded** by that retune (including Oracle wording: high-risk final review / hard debug, **not** "before deploying"; worker doctrine is model-independent, not gpt-5.6-only).

Historical implementation details remain in Git history and the earlier evidence directories; this section documents only the current unreleased contract.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: This changelog edit removes the 2026-07-28 diet/CEO-core rationale that grok-4.5.ts's header comment still points to ('full rationale in changes.md ("Grok 4.5 preset" section)'), leaving a dangling cross-reference. Either retain a one-line pointer noting the diet rationale moved out of the doc, or update the grok-4.5.ts comment to stop referencing this section for it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/coding-agent/src/core/extensions/builtin/prompt-preset/changes.md, line 292:

<comment>This changelog edit removes the 2026-07-28 diet/CEO-core rationale that grok-4.5.ts's header comment still points to ('full rationale in changes.md ("Grok 4.5 preset" section)'), leaving a dangling cross-reference. Either retain a one-line pointer noting the diet rationale moved out of the doc, or update the grok-4.5.ts comment to stop referencing this section for it.</comment>

<file context>
@@ -264,29 +264,32 @@
+
+Grok 4.5 has **not** been formally merged. Do not invent `v1`/`v2`/… edition labels for unreleased retunes — keep a single current section for this feature until it lands. The **Agent-first Implementer/Oracle profiles (2026-08-01)** subsection above is the current design. Historical notes below are retained only for provenance and are **superseded** by that retune (including Oracle wording: high-risk final review / hard debug, **not** "before deploying"; worker doctrine is model-independent, not gpt-5.6-only).
+
+Historical implementation details remain in Git history and the earlier evidence directories; this section documents only the current unreleased contract.
 
 ## Overview
</file context>


## Overview
Per-model prompt preset extension. Selects a tuned system prompt based on the active model and exposes it through the dynamic prompt builder.
Expand Down
Loading
Loading