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.",
193
+
},
194
+
})
195
+
```
196
+
197
+
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"`.
198
+
199
+
#### Customize Mode
200
+
201
+
Use `Mode: "customize"` to selectively override individual sections of the prompt while preserving the rest:
-**`replace`** — Replace the section content entirely
225
+
-**`remove`** — Remove the section from the prompt
226
+
-**`append`** — Add content after the existing section
227
+
-**`prepend`** — Add content before the existing section
228
+
229
+
Unknown section IDs are handled gracefully: content from `replace`/`append`/`prepend` overrides is appended to additional instructions, and `remove` overrides are silently ignored.
230
+
185
231
## Image Support
186
232
187
233
The SDK supports image attachments via the `Attachments` field in `MessageOptions`. You can attach images by providing their file path, or by passing base64-encoded data directly using a blob attachment:
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
@@ -220,6 +220,54 @@ unsubscribe()
220
220
-`session.foreground` - A session became the foreground session in TUI
221
221
-`session.background` - A session is no longer the foreground session
222
222
223
+
### System Message Customization
224
+
225
+
Control the system prompt using `system_message` in session config:
226
+
227
+
```python
228
+
session =await client.create_session(
229
+
system_message={
230
+
"content": "Always check for security vulnerabilities before suggesting changes."
231
+
}
232
+
)
233
+
```
234
+
235
+
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"`.
236
+
237
+
#### Customize Mode
238
+
239
+
Use `mode: "customize"` to selectively override individual sections of the prompt while preserving the rest:
240
+
241
+
```python
242
+
from copilot importSYSTEM_PROMPT_SECTIONS
243
+
244
+
session =await client.create_session(
245
+
system_message={
246
+
"mode": "customize",
247
+
"sections": {
248
+
# Replace the tone/style section
249
+
"tone": {"action": "replace", "content": "Respond in a warm, professional tone. Be thorough in explanations."},
250
+
# Remove coding-specific rules
251
+
"code_change_rules": {"action": "remove"},
252
+
# Append to existing guidelines
253
+
"guidelines": {"action": "append", "content": "\n* Always cite data sources"},
254
+
},
255
+
# Additional instructions appended after all sections
256
+
"content": "Focus on financial analysis and reporting.",
257
+
}
258
+
)
259
+
```
260
+
261
+
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.
262
+
263
+
Each section override supports four actions:
264
+
-**`replace`** — Replace the section content entirely
265
+
-**`remove`** — Remove the section from the prompt
266
+
-**`append`** — Add content after the existing section
267
+
-**`prepend`** — Add content before the existing section
268
+
269
+
Unknown section IDs are handled gracefully: content from `replace`/`append`/`prepend` overrides is appended to additional instructions, and `remove` overrides are silently ignored.
270
+
223
271
### Tools
224
272
225
273
Define tools with automatic JSON schema generation using the `@define_tool` decorator and Pydantic models:
0 commit comments