Skip to content

feat: add systemPromptFile config key for system prompt replacement#57

Closed
rock-solid-sites wants to merge 2 commits into
lessweb:mainfrom
rock-solid-sites:add-system-prompt-file-config
Closed

feat: add systemPromptFile config key for system prompt replacement#57
rock-solid-sites wants to merge 2 commits into
lessweb:mainfrom
rock-solid-sites:add-system-prompt-file-config

Conversation

@rock-solid-sites
Copy link
Copy Markdown
Contributor

Adds a new optional config key systemPromptFile that, when set,
replaces SYSTEM_PROMPT_BASE with the contents of the file at the
given path. Tool docs, runtime context, AGENTS.md, and matched
skills continue to load additively after the replacement prompt.

Motivation: This enables operators to use deepcode-cli with
custom behavioral prompts (e.g., for specialized workflows, team
conventions, or experimental prompt designs) without modifying
source. Tool calling and existing additive layers are preserved.

Implementation:

  • New optional systemPromptFile?: string field in
    DeepcodingSettings and ResolvedDeepcodingSettings
  • Resolution follows the existing precedence: project settings
    override user settings, env vars override both
  • getSystemPrompt() in src/prompt.ts reads the file and uses its
    content in place of SYSTEM_PROMPT_BASE; tool docs and runtime
    context still append after
  • Fail-loud on file read failure (throws with the resolved path
    and OS error) — silent fallback to default would hide
    configuration bugs

Testing:

  • Typecheck, lint, and bundle all pass
  • Existing test suite passes (except pre-existing platform-specific
    failures unrelated to this change)
  • Manual verification: with a test file containing "always start
    responses with TACOS", confirmed the model produces TACOS-
    prefixed responses and tool calls still work; with a nonexistent
    path, confirmed the fail-loud error fires

Open to feedback on naming, fallback behavior, or whether a CLI
flag (--system-prompt-file) should accompany the config key.

Add a new optional config key 'systemPromptFile' to settings.json
that replaces the built-in SYSTEM_PROMPT_BASE with custom content.
Tool docs, runtime context, AGENTS.md, and matched skills continue
to load after the replacement — only the content of the first system
message changes.

- src/settings.ts: Add systemPromptFile to DeepcodingSettings and
  ResolvedDeepcodingSettings types. Resolve with standard precedence
  (system env > project settings > user settings).
- src/prompt.ts: Extend getSystemPrompt() with a systemPromptFile
  parameter. When set, reads the file at the resolved path and uses
  it as the base prompt. Fails loud if the file can't be read.
- src/session.ts: Plumb systemPromptFile through SessionManager via
  getResolvedSettings callback into createSession().
Add the new systemPromptFile field to the settings table and
a dedicated section explaining path resolution, behavior, and
the fail-loud error handling (no silent fallback to default).
@rock-solid-sites rock-solid-sites force-pushed the add-system-prompt-file-config branch from e8023c4 to c07dda5 Compare May 13, 2026 21:57
@qorzj
Copy link
Copy Markdown
Collaborator

qorzj commented May 14, 2026

@rock-solid-sites Thanks for the contribution! However, Deep Code already loads AGENTS.md as system-level instructions (i.e. system prompt) for the LLM. Is there a specific use case where AGENTS.md isn't sufficient?

@rock-solid-sites
Copy link
Copy Markdown
Contributor Author

AGENTS.md is project-scoped and lives in the workspace, while behavioral presets are session-scoped and live in the user's config. They serve different purposes. AGENTS.md says "here's what's true about this project" — paths, conventions, gotchas. A behavioral preset says "act this way regardless of what project you're in" — posture, autonomy level, communication style. A user wants to switch between "safe-and-collaborative" and "autonomous-and-fast" without editing every project's AGENTS.md. And the prior investigation confirmed AGENTS.md is additive, wrapped in <project_instructions> and placed after the mode prompt — so even using it for behavioral tuning runs into the same dilution problem skills have.

@qorzj qorzj closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants