Skip to content

feat(config): inject configurable files into the system prompt#157

Open
ryuhaneul wants to merge 1 commit into
PleasePrompto:mainfrom
ryuhaneul:feat/append-system-prompt-files
Open

feat(config): inject configurable files into the system prompt#157
ryuhaneul wants to merge 1 commit into
PleasePrompto:mainfrom
ryuhaneul:feat/append-system-prompt-files

Conversation

@ryuhaneul

Copy link
Copy Markdown
Contributor

Motivation

Ductor already auto-appends MAINMEMORY.md to the system prompt (on new sessions), but there's no way to inject additional files — extra context or reference documents — that you want present on every turn. This adds a small config option to do exactly that.

What it adds

  • New config key append_system_prompt_files: list[str] (default []): a list of workspace-relative filenames whose contents are appended to the agent's --append-system-prompt for agent-driven turns.
    • List multiple files to inject several — they're concatenated in the listed order, e.g. "append_system_prompt_files": ["GLOSSARY.md", "STYLE_GUIDE.md"].
  • Each agent reads the files from its own workspace, so the main agent and each sub-agent can carry different content under the same filenames. Sub-agents inherit the list from the main config.
  • Injected on every turn (not just new sessions), so it survives compaction — like the existing MAINMEMORY.md mechanism, but always-on.

Where it injects (and where it doesn't)

Wired into the agent-driven request paths: normal chat, named sessions (sync + streaming), inter-agent messages (incl. retry), tasks, and background named sessions. Intentionally excluded from system-maintenance turns — heartbeat, memory flush, and compaction.

Safety

  • Default [] → no change to current behavior.
  • Missing files are silently skipped (no error).
  • Filenames are confined to the workspace: absolute paths, .., and symlink escapes are ignored (resolved and checked against the workspace root).

Tests

Coverage for the helper (concat / empty / missing / path-escape guards), every-turn injection (including resume), per-agent workspace resolution, and the maintenance-flow exclusions.

…pend_system_prompt_files

Add an opt-in append_system_prompt_files list to AgentConfig: each
workspace-relative filename's contents are appended to the system prompt
of agent-driven turns. Default empty list preserves current behavior, and
missing/empty files are skipped silently.

A shared async helper build_appended_files_block reads the files from the
agent's own workspace, with a resolve()+is_relative_to path-escape guard
(absolute paths, .., and workspace symlinks escaping the workspace are
skipped). It returns None when nothing applies so callers leave
append_system_prompt unchanged.

Wired into the 8 agent-driven AgentRequest points: normal turns
(_prepare_normal, every turn after mainmemory/roster), named-session flow +
streaming, inter-agent injection (_inject_prompt, interagent message,
retry), the task hub, and background named sessions. The task hub resolves
each task's parent-agent workspace; the background observer gains a config
param. MAINMEMORY injection is unchanged.

The maintenance flows are intentionally excluded (no injection): heartbeat,
memory flush, and memory compaction.
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.

1 participant