Skip to content

Java: Make it so slash command responses are accessible via RPC#1520

Open
edburns wants to merge 6 commits into
mainfrom
edburns/java-slash-command-tests
Open

Java: Make it so slash command responses are accessible via RPC#1520
edburns wants to merge 6 commits into
mainfrom
edburns/java-slash-command-tests

Conversation

@edburns
Copy link
Copy Markdown
Collaborator

@edburns edburns commented May 30, 2026

Java

Last minute gap analysis promted by this question by Zidong Li:

Just curious whether you know how to trigger slash commands in SDK. There's one kind of skill that disables agents calling. Those skills can be invoked in copilot cli by / manually. But using SDKs, if I send the text directly to agents, it's just treated as plain text to LLM, but LLM actually doesn't have the skill in context so it will not invoke the skill. Did you know any conversation about this?

prompted me to investigate this. Turns out the ability to invoke slash commands was there, but the ability to obtain the responses was not.

edburns and others added 2 commits May 30, 2026 13:49
Fix the Java codegen to produce proper return types for RPC methods
whose result schema uses $ref to named definitions. Previously these
all fell through to CompletableFuture<Void>.

Changes to java/scripts/codegen/java.ts:
- Add findDiscriminator() to detect anyOf unions with a shared const
  property (ported from the C# codegen pattern)
- Add generatePolymorphicResultClass() and variant class generation
  using Jackson @JsonTypeInfo/@JsonSubTypes annotations
- Update wrapperResultClassName() to recognize $ref to enums, anyOf
  discriminated unions, and named empty objects
- Update generateRpcTypes() to generate appropriate classes for each
  result schema pattern (enum, anyOf, empty object)
- Update generatePendingStandaloneTypes() to handle anyOf schemas

Affected API methods:
- session.commands.invoke → CompletableFuture<SlashCommandInvocationResult>
  (polymorphic: text, agent-prompt, completed, select-subcommand)
- session.mode.get → CompletableFuture<SessionMode> (string enum)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 30, 2026 20:54
@edburns edburns requested a review from a team as a code owner May 30, 2026 20:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

edburns added 3 commits May 30, 2026 15:14
On branch edburns/java-slash-command-tests
modified:   java/src/test/java/com/github/copilot/SlashCommandsIT.java
On branch edburns/java-slash-command-tests
modified:   java/src/test/java/com/github/copilot/TestUtil.java
modified:   java/src/test/java/com/github/copilot/generated/GeneratedTypesJacksonRoundTripTest.java

no changes added to commit (use "git add" and/or "git commit -a")
On branch edburns/java-slash-command-tests
modified:   java/src/test/java/com/github/copilot/TestUtil.java
modified:   java/src/test/java/com/github/copilot/generated/GeneratedTypesJacksonRoundTripTest.java

no changes added to commit (use "git add" and/or "git commit -a")
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.

2 participants