Skip to content

Rename SystemPromptSections → SystemMessageSections for cross-SDK consistency#1683

Merged
edburns merged 8 commits into
mainfrom
edburns/1679-java-consistency-system-message-sections
Jun 16, 2026
Merged

Rename SystemPromptSections → SystemMessageSections for cross-SDK consistency#1683
edburns merged 8 commits into
mainfrom
edburns/1679-java-consistency-system-message-sections

Conversation

@edburns

@edburns edburns commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

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

@edburns edburns self-assigned this Jun 15, 2026
@edburns edburns marked this pull request as ready for review June 15, 2026 23:04
@edburns edburns requested a review from a team as a code owner June 15, 2026 23:04
Copilot AI review requested due to automatic review settings June 15, 2026 23:04
@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by SDK Consistency Review Agent for issue #1683 · sonnet46 1.5M

Comment thread java/src/main/java/com/github/copilot/rpc/SystemPromptSections.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the Java SDK’s public API terminology with other Copilot SDKs by introducing SystemMessageSections and deprecating the older SystemPromptSections name while keeping existing callers working.

Changes:

  • Added SystemMessageSections as the new canonical constants holder for system message section identifiers.
  • Deprecated SystemPromptSections and converted it into a thin compatibility subclass.
  • Updated JavaDoc references and added a failsafe integration test validating that key section IDs are recognized by the live CLI and that legacy constants match.
Show a summary per file
File Description
java/src/main/java/com/github/copilot/rpc/SystemMessageSections.java Adds new public constants class for system message section identifiers.
java/src/main/java/com/github/copilot/rpc/SystemPromptSections.java Deprecates legacy name and routes constants through the new type.
java/src/main/java/com/github/copilot/rpc/SystemMessageConfig.java Updates JavaDoc examples/references to use SystemMessageSections.
java/src/main/java/com/github/copilot/rpc/SectionOverride.java Updates JavaDoc terminology and references to SystemMessageSections.
java/src/test/java/com/github/copilot/SystemMessageSectionsIT.java Adds live-CLI integration coverage for section transforms and legacy equivalence.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread java/src/main/java/com/github/copilot/rpc/SystemPromptSections.java Outdated
Comment thread java/src/main/java/com/github/copilot/rpc/SystemMessageSections.java Outdated
@github-actions

This comment has been minimized.

edburns and others added 2 commits June 15, 2026 19:43
…sistency

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>
Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
@edburns edburns force-pushed the edburns/1679-java-consistency-system-message-sections branch from dcacb9b to f0e7b86 Compare June 15, 2026 23:44
@github-actions

This comment has been minimized.

…sed 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>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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>
@github-actions

This comment has been minimized.

…sistency

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`.
@github-actions

This comment has been minimized.

edburns and others added 2 commits June 16, 2026 13:23
…-sections

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR correctly addresses a cross-SDK naming inconsistency in the Java SDK. Here's the analysis:

What was inconsistent (before this PR)

The Java SDK used SystemPromptSections (with "Prompt"), while every other SDK already used the "SystemMessage" naming:

SDK Section constants container
Node.js/TS SystemMessageSection type + SYSTEM_MESSAGE_SECTIONS constant
Python SystemMessageSection Literal type + SYSTEM_MESSAGE_SECTIONS dict
Go SectionIdentity, SectionTone, ... top-level constants
.NET SystemMessageSection struct with static properties
Java (before) SystemPromptSections class ❌
Java (this PR) SystemMessageSections class ✅

Section identifier values — all 11 match across SDKs ✅

All string values ("identity", "tone", "tool_efficiency", "environment_context", "code_change_rules", "guidelines", "safety", "tool_instructions", "custom_instructions", "runtime_instructions", "last_instructions") are identical across Java, Node.js, Python, Go, and .NET.

Backward compatibility ✅

The sealed-class hierarchy approach (SystemPromptSections extends SystemMessageSections) preserves backward compatibility appropriately. No other SDK ever exposed a SystemPromptSections equivalent so no cross-SDK change is needed there.

Minor pre-existing gap (not introduced by this PR)

The Rust SDK does not expose named section constants — SystemMessageConfig.sections accepts HashMap<String, SectionOverride> with raw string keys. This is a pre-existing inconsistency not introduced here, but worth tracking as a follow-up improvement for Rust parity.

Other changes (Javadoc @since corrections) ✅

The @since 1.2.0@since 1.0.0 corrections across multiple files are Java-internal documentation fixes that don't affect cross-SDK API surface.


Verdict: The PR successfully brings the Java SDK into naming alignment with Node.js, Python, Go, and .NET. No cross-language follow-up changes are required by this PR.

Generated by SDK Consistency Review Agent for issue #1683 · sonnet46 1.6M ·

@edburns edburns merged commit 2320ea8 into main Jun 16, 2026
40 checks passed
@edburns edburns deleted the edburns/1679-java-consistency-system-message-sections branch June 16, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java: Consistency: SystemPromptSections → SystemMessageSections

3 participants