MCPcopy Index your code
hub / github.com/github/copilot-sdk / systemMessageForMode

Method systemMessageForMode

go/mode_empty.go:80–117  ·  view source on GitHub ↗

systemMessageForMode applies empty-mode environment_context stripping to the caller-supplied system message config. App values win (we only inject when the app hasn't already specified an environment_context override).

(supplied *SystemMessageConfig)

Source from the content-addressed store, hash-verified

78// the caller-supplied system message config. App values win (we only inject
79// when the app hasn't already specified an environment_context override).
80func (c *Client) systemMessageForMode(supplied *SystemMessageConfig) *SystemMessageConfig {
81 if c.options.Mode != ModeEmpty {
82 return supplied
83 }
84 removeAction := SectionOverride{Action: SectionActionRemove}
85 if supplied == nil {
86 return &SystemMessageConfig{
87 Mode: "customize",
88 Sections: map[string]SectionOverride{"environment_context": removeAction},
89 }
90 }
91 switch supplied.Mode {
92 case "replace":
93 return supplied
94 case "customize":
95 if _, ok := supplied.Sections["environment_context"]; ok {
96 return supplied
97 }
98 out := *supplied
99 out.Sections = make(map[string]SectionOverride, len(supplied.Sections)+1)
100 for k, v := range supplied.Sections {
101 out.Sections[k] = v
102 }
103 out.Sections["environment_context"] = removeAction
104 return &out
105 case "append", "":
106 // Promote append/unspecified to customize so we can also strip
107 // environment_context. The runtime appends Content to additional
108 // instructions in both modes, so caller text is preserved verbatim.
109 return &SystemMessageConfig{
110 Mode: "customize",
111 Content: supplied.Content,
112 Sections: map[string]SectionOverride{"environment_context": removeAction},
113 }
114 default:
115 return supplied
116 }
117}
118
119// applyConfigDefaultsForMode fills in empty-mode defaults on the session
120// config in place. App-supplied values win.

Calls

no outgoing calls