SC-4 System prompt template swap (resolveSystemPrompt at dispatch) #626

Closed
opened 2026-05-01 10:33:42 +00:00 by claude-desktop · 0 comments
Collaborator

User story

As a platform engineer, I want the dispatch path to read the system prompt template through resolveSystemPrompt(agent) instead of the in-memory agents.json::types[].system_prompt_template object, so that operator edits at any scope (global / agent_type / instance) take effect on the next dispatch without a service restart.

Acceptance criteria

Source-of-truth swap

  • Replace every consumer of types[t].system_prompt_template and types[t].default_system_prompt in the dispatch path (likely apps/server/src/domain/agent/agent-runner.ts and any helper under apps/server/src/domain/dispatch/ that builds the agent's first turn) with resolveSystemPrompt(agent).
  • Existing ${repo}, ${issue_number}, ${if:parent_pr}…${endif} interpolation logic is unchanged. Only the source of the template moves from agents.json (in-memory config object) to the resolver.
  • default_system_prompt and system_prompt_template in agents.json become builtin-only inputs — builtin-sync reads them and writes one system_prompt row per type (scope = 'builtin', agent_type = <type>).

Render-to-disk integration

  • agent-env-sync.renderForInstance (SC-2) writes <env-dir>/system-prompt.md from resolveSystemPrompt(agent) so the per-instance file mirrors the resolved template. The dispatch path may read this file instead of calling the resolver directly — pick one path and document it in the handler docstring.

Tests

  • Existing dispatch / agent-runner tests pass without modification.
  • New unit: an instance-scope system_prompt row produces a different prompt than the agent-type sibling on the same dispatch.
  • New unit: editing a builtin row (drift detection in builtin-sync) re-syncs only scope = 'builtin'; an existing agent_type override is preserved.

Out of scope

  • Plugin / MCP swap (SC-5).
  • HTTP routes / UI (SC-7+).

References

  • specs/agent-config-customization.md §Story SC-4
  • apps/server/src/domain/agent/agent-runner.ts — first-turn construction
  • apps/server/src/shared/config/agents-config-schema.tssystem_prompt_template / default_system_prompt field definitions
  • Depends on SC-1 (resolver) and SC-2 (renderer for the on-disk view).
## User story As a platform engineer, I want the dispatch path to read the system prompt template through `resolveSystemPrompt(agent)` instead of the in-memory `agents.json::types[].system_prompt_template` object, so that operator edits at any scope (global / agent_type / instance) take effect on the next dispatch without a service restart. ## Acceptance criteria ### Source-of-truth swap - [ ] Replace every consumer of `types[t].system_prompt_template` and `types[t].default_system_prompt` in the dispatch path (likely `apps/server/src/domain/agent/agent-runner.ts` and any helper under `apps/server/src/domain/dispatch/` that builds the agent's first turn) with `resolveSystemPrompt(agent)`. - [ ] Existing `${repo}`, `${issue_number}`, `${if:parent_pr}…${endif}` interpolation logic is unchanged. Only the **source** of the template moves from `agents.json` (in-memory config object) to the resolver. - [ ] `default_system_prompt` and `system_prompt_template` in `agents.json` become builtin-only inputs — `builtin-sync` reads them and writes one `system_prompt` row per type (`scope = 'builtin'`, `agent_type = <type>`). ### Render-to-disk integration - [ ] `agent-env-sync.renderForInstance` (SC-2) writes `<env-dir>/system-prompt.md` from `resolveSystemPrompt(agent)` so the per-instance file mirrors the resolved template. The dispatch path may read this file instead of calling the resolver directly — pick one path and document it in the handler docstring. ### Tests - [ ] Existing dispatch / agent-runner tests pass without modification. - [ ] New unit: an `instance`-scope `system_prompt` row produces a different prompt than the agent-type sibling on the same dispatch. - [ ] New unit: editing a builtin row (drift detection in builtin-sync) re-syncs only `scope = 'builtin'`; an existing `agent_type` override is preserved. ## Out of scope - Plugin / MCP swap (SC-5). - HTTP routes / UI (SC-7+). ## References - `specs/agent-config-customization.md` §Story SC-4 - `apps/server/src/domain/agent/agent-runner.ts` — first-turn construction - `apps/server/src/shared/config/agents-config-schema.ts` — `system_prompt_template` / `default_system_prompt` field definitions - Depends on **SC-1** (resolver) and **SC-2** (renderer for the on-disk view).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#626
No description provided.