Problem
Worker prompts are built by string concatenation in BuildWorkerPrompt() (CopilotService.Organization.cs line ~2829). This concatenates identity, worktree note, shared prefix, original prompt, and task into one big string. The SDK provides a structured SystemMessageConfig with SectionOverride that can append/prepend/replace system prompt sections — a cleaner approach.
SDK APIs Available
SessionConfig.SystemMessage — SystemMessageConfig with:
Mode — append/prepend/replace
Content — raw content
Sections — dictionary of SectionOverride per section name
SectionOverride — Action (append/prepend/replace), Content, Transform (dynamic)
SystemPromptSections — enum of known section names
What to Change
- Instead of string concatenation in
BuildWorkerPrompt, use SessionConfig.SystemMessage with section overrides
- Worker charter goes in the appropriate section, worktree note in another, shared context in another
- This gives the SDK control over section ordering and prevents accidental clobbering
- The current approach works but is fragile — adding a new section requires modifying the concatenation order
Risk
Low — this is a refactor of prompt construction, not a behavior change. The prompt content stays the same, just delivered through the SDK's structured system.
Problem
Worker prompts are built by string concatenation in
BuildWorkerPrompt()(CopilotService.Organization.csline ~2829). This concatenates identity, worktree note, shared prefix, original prompt, and task into one big string. The SDK provides a structuredSystemMessageConfigwithSectionOverridethat can append/prepend/replace system prompt sections — a cleaner approach.SDK APIs Available
SessionConfig.SystemMessage—SystemMessageConfigwith:Mode— append/prepend/replaceContent— raw contentSections— dictionary ofSectionOverrideper section nameSectionOverride—Action(append/prepend/replace),Content,Transform(dynamic)SystemPromptSections— enum of known section namesWhat to Change
BuildWorkerPrompt, useSessionConfig.SystemMessagewith section overridesRisk
Low — this is a refactor of prompt construction, not a behavior change. The prompt content stays the same, just delivered through the SDK's structured system.