Skip to content

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

Merged
edburns merged 10 commits into
mainfrom
edburns/java-slash-command-tests
May 31, 2026
Merged

Java: Make it so slash command responses are accessible via RPC#1520
edburns merged 10 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.

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 and others added 10 commits May 31, 2026 02:44
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>
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")
On branch edburns/java-slash-command-tests
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   java/pom.xml

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/SlashCommandsIT.java
On branch edburns/java-slash-command-tests
modified:   java/src/test/java/com/github/copilot/SlashCommandsIT.java

no changes added to commit (use "git add" and/or "git commit -a")
@edburns edburns force-pushed the edburns/java-slash-command-tests branch from 11aa504 to 9c39e91 Compare May 31, 2026 09:46
@edburns edburns merged commit 4d2df4c into main May 31, 2026
23 checks passed
@edburns edburns deleted the edburns/java-slash-command-tests branch May 31, 2026 09:52
@edburns
Copy link
Copy Markdown
Collaborator Author

edburns commented May 31, 2026

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