Commit 005b780
Add fine-grained system prompt customization (customize mode) (#816)
* Add fine-grained system prompt customization (customize mode)
Add a new 'customize' mode for systemMessage configuration, enabling
SDK consumers to selectively override individual sections of the CLI
system prompt while preserving the rest. This sits between the existing
'append' and 'replace' modes.
9 configurable sections: identity, tone, tool_efficiency,
environment_context, code_change_rules, guidelines, safety,
tool_instructions, custom_instructions.
4 override actions per section: replace, remove, append, prepend.
Unknown section IDs are handled gracefully: content-bearing overrides
are appended to additional instructions with a warning, and remove
on unknown sections is silently ignored.
Types and constants added to all 4 SDK languages (TypeScript, Python,
Go, .NET). Documentation updated across all READMEs and getting-started
guide.
Companion runtime PR: github/copilot-agent-runtime#4751
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address PR review feedback: fix docs, add examples and E2E tests
- 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>
* Add last_instructions configurable section
Expose lastInstructions as a customizable section across all 4 SDKs,
addressing review feedback about duplicate tool-efficiency blocks.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix lint: prettier formatting, Python import order and line length
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add transform operation for system prompt section customization
Adds a new 'transform' action to SectionOverride that enables read-then-write
mutation of system prompt sections via callbacks. The SDK intercepts function-
valued actions before serialization, stores the callbacks locally, and handles
the batched systemMessage.transform JSON-RPC callback from the runtime.
Changes across all 4 SDKs (TypeScript, Python, Go, .NET):
- Types: SectionTransformFn, SectionOverrideAction (TS/Python), Transform
field (Go/.NET), SectionOverrideAction constants (Go)
- Client: extractTransformCallbacks helper, transform callback registration,
systemMessage.transform RPC handler
- Session: transform callback storage and batched dispatch with error handling
- E2E tests and shared snapshot YAML files
Wire protocol: single batched RPC call with all transform sections, matching
the runtime implementation in copilot-agent-runtime PR #5103.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Formatting
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
* Add E2E snapshot for customized systemMessage config test
Generate the missing snapshot file that the 'should create a session
with customized systemMessage config' test requires across all SDK
languages (Node, Python, Go, .NET).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Go fmt blank comment line and Python import ordering
- Add blank // comment line between doc example and extractTransformCallbacks
function doc comment in go/client.go (required by go fmt)
- Fix ruff import sorting in python/copilot/__init__.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Python ty type error in session transform handler
Use str() to ensure transform callback result is typed as str,
fixing the invalid-assignment error from ty type checker at
session.py:689.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Python E2E test to use keyword args for create_session
The create_session() method was refactored to keyword-only params.
Update the customized systemMessage test to use keyword arguments
instead of a positional dict, and fix send_and_wait() call to pass
prompt as a positional string.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Assert transform result in system message via HTTP traffic
The 'should apply transform modifications' tests previously only verified
that the transform callback was invoked, not that the transformed content
actually reached the model. Now all 4 SDKs assert that TRANSFORM_MARKER
appears in the system message captured from HTTP traffic.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix Go transform JSON serialization: add json tags for content field
The systemMessageTransformRequest and systemMessageTransformResponse
used anonymous structs without json tags, causing Content to serialize
as uppercase 'Content' instead of lowercase 'content'. The CLI expects
lowercase, so transform results were silently ignored.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Steve Sanderson <SteveSandersonMS@users.noreply.github.com>1 parent a124096 commit 005b780
File tree
32 files changed
+1955
-45
lines changed- docs
- dotnet
- src
- test
- go
- internal/e2e
- nodejs
- src
- test/e2e
- python
- copilot
- e2e
- test/snapshots
- session
- system_message_transform
32 files changed
+1955
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
1238 | | - | |
| 1238 | + | |
1239 | 1239 | | |
1240 | 1240 | | |
1241 | 1241 | | |
| |||
1245 | 1245 | | |
1246 | 1246 | | |
1247 | 1247 | | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
1248 | 1270 | | |
1249 | 1271 | | |
1250 | 1272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
512 | 540 | | |
513 | 541 | | |
514 | 542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
368 | 406 | | |
369 | 407 | | |
370 | 408 | | |
| |||
409 | 447 | | |
410 | 448 | | |
411 | 449 | | |
| 450 | + | |
| 451 | + | |
412 | 452 | | |
413 | 453 | | |
414 | 454 | | |
| |||
424 | 464 | | |
425 | 465 | | |
426 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
427 | 471 | | |
428 | 472 | | |
429 | 473 | | |
| |||
440 | 484 | | |
441 | 485 | | |
442 | 486 | | |
443 | | - | |
| 487 | + | |
444 | 488 | | |
445 | 489 | | |
446 | 490 | | |
| |||
519 | 563 | | |
520 | 564 | | |
521 | 565 | | |
| 566 | + | |
| 567 | + | |
522 | 568 | | |
523 | 569 | | |
524 | 570 | | |
| |||
532 | 578 | | |
533 | 579 | | |
534 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
535 | 585 | | |
536 | 586 | | |
537 | 587 | | |
| |||
548 | 598 | | |
549 | 599 | | |
550 | 600 | | |
551 | | - | |
| 601 | + | |
552 | 602 | | |
553 | 603 | | |
554 | 604 | | |
| |||
1222 | 1272 | | |
1223 | 1273 | | |
1224 | 1274 | | |
| 1275 | + | |
1225 | 1276 | | |
1226 | 1277 | | |
1227 | 1278 | | |
| |||
1350 | 1401 | | |
1351 | 1402 | | |
1352 | 1403 | | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
1353 | 1410 | | |
1354 | 1411 | | |
1355 | 1412 | | |
| |||
1685 | 1742 | | |
1686 | 1743 | | |
1687 | 1744 | | |
| 1745 | + | |
1688 | 1746 | | |
1689 | 1747 | | |
1690 | 1748 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 19 | + | |
23 | 20 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| |||
653 | 655 | | |
654 | 656 | | |
655 | 657 | | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
656 | 724 | | |
657 | 725 | | |
658 | 726 | | |
| |||
891 | 959 | | |
892 | 960 | | |
893 | 961 | | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
894 | 965 | | |
895 | 966 | | |
0 commit comments