You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Fix incorrect package name in nodejs/README.md (@anthropic-ai/sdk -> @github/copilot-sdk)
- Add standalone 'System Message Customization' sections with full
code examples to Python and Go READMEs (matching TypeScript/.NET)
- Add E2E tests for customize mode to Python, Go, and .NET
(matching existing Node.js E2E test coverage)
- Fix 'end of the prompt' wording in docs to 'additional instructions'
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Content: "Always check for security vulnerabilities before suggesting changes.",
189
+
},
190
+
})
191
+
```
192
+
193
+
The SDK auto-injects environment context, tool instructions, and security guardrails. The default CLI persona is preserved, and your `Content` is appended after SDK-managed sections. To change the persona or fully redefine the prompt, use `Mode: "replace"` or `Mode: "customize"`.
194
+
195
+
#### Customize Mode
196
+
197
+
Use `Mode: "customize"` to selectively override individual sections of the prompt while preserving the rest:
-**`replace`** — Replace the section content entirely
221
+
-**`remove`** — Remove the section from the prompt
222
+
-**`append`** — Add content after the existing section
223
+
-**`prepend`** — Add content before the existing section
224
+
225
+
Unknown section IDs are handled gracefully: content from `replace`/`append`/`prepend` overrides is appended to additional instructions, and `remove` overrides are silently ignored.
226
+
181
227
## Image Support
182
228
183
229
The SDK supports image attachments via the `Attachments` field in `MessageOptions`. You can attach images by providing their file path:
Copy file name to clipboardExpand all lines: python/README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,6 +158,54 @@ unsubscribe()
158
158
-`session.foreground` - A session became the foreground session in TUI
159
159
-`session.background` - A session is no longer the foreground session
160
160
161
+
### System Message Customization
162
+
163
+
Control the system prompt using `system_message` in session config:
164
+
165
+
```python
166
+
session =await client.create_session(
167
+
system_message={
168
+
"content": "Always check for security vulnerabilities before suggesting changes."
169
+
}
170
+
)
171
+
```
172
+
173
+
The SDK auto-injects environment context, tool instructions, and security guardrails. The default CLI persona is preserved, and your `content` is appended after SDK-managed sections. To change the persona or fully redefine the prompt, use `mode: "replace"` or `mode: "customize"`.
174
+
175
+
#### Customize Mode
176
+
177
+
Use `mode: "customize"` to selectively override individual sections of the prompt while preserving the rest:
178
+
179
+
```python
180
+
from copilot importSYSTEM_PROMPT_SECTIONS
181
+
182
+
session =await client.create_session(
183
+
system_message={
184
+
"mode": "customize",
185
+
"sections": {
186
+
# Replace the tone/style section
187
+
"tone": {"action": "replace", "content": "Respond in a warm, professional tone. Be thorough in explanations."},
188
+
# Remove coding-specific rules
189
+
"code_change_rules": {"action": "remove"},
190
+
# Append to existing guidelines
191
+
"guidelines": {"action": "append", "content": "\n* Always cite data sources"},
192
+
},
193
+
# Additional instructions appended after all sections
194
+
"content": "Focus on financial analysis and reporting.",
195
+
}
196
+
)
197
+
```
198
+
199
+
Available section IDs: `"identity"`, `"tone"`, `"tool_efficiency"`, `"environment_context"`, `"code_change_rules"`, `"guidelines"`, `"safety"`, `"tool_instructions"`, `"custom_instructions"`. Use the `SYSTEM_PROMPT_SECTIONS` dict for descriptions of each section.
200
+
201
+
Each section override supports four actions:
202
+
-**`replace`** — Replace the section content entirely
203
+
-**`remove`** — Remove the section from the prompt
204
+
-**`append`** — Add content after the existing section
205
+
-**`prepend`** — Add content before the existing section
206
+
207
+
Unknown section IDs are handled gracefully: content from `replace`/`append`/`prepend` overrides is appended to additional instructions, and `remove` overrides are silently ignored.
208
+
161
209
### Tools
162
210
163
211
Define tools with automatic JSON schema generation using the `@define_tool` decorator and Pydantic models:
0 commit comments