Commit 2320ea8
Rename SystemPromptSections → SystemMessageSections for cross-SDK consistency (#1683)
* Rename SystemPromptSections → SystemMessageSections for cross-SDK consistency
Introduce `SystemMessageSections` as a sealed superclass containing all
well-known section identifier constants. The existing `SystemPromptSections`
becomes a deprecated final subclass that inherits everything unchanged,
preserving backward compatibility.
New files:
- `SystemMessageSections.java`: Sealed class with all `public static final
String` constants (IDENTITY, TONE, TOOL_EFFICIENCY, etc.) and Javadoc
matching the naming convention used by Node, Python, .NET, Go, and Rust SDKs.
- `SystemMessageSectionsIT.java`: Failsafe integration test that validates
transform callbacks on IDENTITY and TONE sections receive non-empty content
from the live CLI, plus an equivalence test ensuring the deprecated subclass
inherits all constants correctly.
Modified files:
- `SystemPromptSections.java`: Gutted to an empty `@Deprecated(since="1.0.2",
forRemoval=true)` final class extending `SystemMessageSections`.
- `SystemMessageConfig.java`: Updated Javadoc references from
`SystemPromptSections` to `SystemMessageSections`.
- `SectionOverride.java`: Updated Javadoc references from
`SystemPromptSections` to `SystemMessageSections`.
Fixes #1679
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(java): address review feedback for system message sections
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
* Fix SystemMessageSectionsIT: remove live-auth test, add reflection-based inheritance tests
The transform test required live CLI authentication which is unavailable in
CI. Replace it with three tests that validate the sealed hierarchy without
needing a live session:
1. deprecatedSystemPromptSectionsMatchesSystemMessageSections — value equality
2. systemPromptSectionsExtendsSystemMessageSections — class hierarchy check
3. allConstantsInheritedByDeprecatedClass — reflection-based exhaustive check
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix SystemMessageSectionsIT: use replay proxy for transform test
Replace the live-auth transform test with an E2E test that uses the
replay proxy and the existing system_message_transform snapshot. This
works in CI without requiring authenticated CLI access.
The test now has three methods:
- transformOnIdentitySectionReceivesNonEmptyContent: E2E via replay proxy
- deprecatedSystemPromptSectionsMatchesSystemMessageSections: value equality
- allConstantsInheritedByDeprecatedClass: reflection-based inheritance check
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Rename SystemPromptSections → SystemMessageSections for cross-SDK consistency
Fixes #1679
## Summary
Introduces `SystemMessageSections` as the canonical class for section
constants in the Java SDK, aligning with the naming used in .NET, Python,
and other SDKs. The previous `SystemPromptSections` class is preserved as a
deprecated subclass for backward compatibility.
## Changes
### New files
- `java/src/main/java/com/github/copilot/rpc/SystemMessageSections.java`
Sealed superclass containing all 11 system message section constants
(IDENTITY, INSTRUCTIONS, CONTEXT, TOOL_HANDLING, etc.) with full Javadoc.
Permits only `SystemPromptSections` as a subclass.
- `java/src/test/java/com/github/copilot/SystemMessageSectionsIT.java`
Failsafe integration test with 4 test methods:
1. `transformOnIdentitySectionReceivesNonEmptyContent` — verifies that the
transform callback fires with real section content using the replay proxy.
2. `deprecatedClassReferencesAreEquivalent` — confirms that constants accessed
via the deprecated `SystemPromptSections` are identical to `SystemMessageSections`.
3. `allConstantsInheritedByDeprecatedClass` — reflection-based exhaustive check
that all 11 constants are inherited correctly.
4. `shouldUseReplacedIdentitySectionInResponse` — E2E test proving that
`SectionOverrideAction.REPLACE` on the IDENTITY section causes the assistant
to adopt a custom identity (Botanica gardening assistant).
- `test/snapshots/system_message_sections/should_use_replaced_identity_section_in_response.yaml`
Handcrafted replay proxy snapshot for the REPLACE identity test. Contains a
single conversation: user asks "Who are you?", assistant responds as Botanica.
### Modified files
- `java/src/main/java/com/github/copilot/rpc/SystemPromptSections.java`
Gutted to a deprecated final subclass that extends `SystemMessageSections`.
All constants are now inherited from the parent. Marked
`@Deprecated(since = "1.0.2", forRemoval = true)`.
- `java/src/main/java/com/github/copilot/rpc/SystemMessageConfig.java`
Updated Javadoc `@see` references from `SystemPromptSections` to
`SystemMessageSections`.
- `java/src/main/java/com/github/copilot/rpc/SectionOverride.java`
Updated Javadoc `@see` references from `SystemPromptSections` to
`SystemMessageSections`.
* Correct bogus @SInCE values
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>1 parent 1d61f7a commit 2320ea8
15 files changed
Lines changed: 316 additions & 86 deletions
File tree
- java/src
- main/java/com/github/copilot
- rpc
- test/java/com/github/copilot
- test/snapshots/system_message_sections
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1818 | 1818 | | |
1819 | 1819 | | |
1820 | 1820 | | |
1821 | | - | |
| 1821 | + | |
1822 | 1822 | | |
1823 | 1823 | | |
1824 | 1824 | | |
| |||
1958 | 1958 | | |
1959 | 1959 | | |
1960 | 1960 | | |
1961 | | - | |
| 1961 | + | |
1962 | 1962 | | |
1963 | 1963 | | |
1964 | 1964 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
515 | | - | |
| 515 | + | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
| 530 | + | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
Lines changed: 9 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 10 | + | |
| 11 | + | |
14 | 12 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
27 | 17 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 18 | + | |
| 19 | + | |
71 | 20 | | |
72 | 21 | | |
73 | | - | |
74 | 22 | | |
75 | 23 | | |
0 commit comments