Skip to content

feat: Use SystemMessageConfig with SectionOverride for worker prompts #496

@PureWeen

Description

@PureWeen

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.SystemMessageSystemMessageConfig with:
    • Mode — append/prepend/replace
    • Content — raw content
    • Sections — dictionary of SectionOverride per section name
  • SectionOverrideAction (append/prepend/replace), Content, Transform (dynamic)
  • SystemPromptSections — enum of known section names

What to Change

  1. Instead of string concatenation in BuildWorkerPrompt, use SessionConfig.SystemMessage with section overrides
  2. Worker charter goes in the appropriate section, worktree note in another, shared context in another
  3. This gives the SDK control over section ordering and prevents accidental clobbering
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions