Reference implementation sync: 41 new commits (2026-04-20)#87
Reference implementation sync: 41 new commits (2026-04-20)#87
Conversation
…ilitiesOverride, agent skills, per-request headers Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/514da8aa-3336-46ca-b39a-48faabcbb354 Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
edburns
left a comment
There was a problem hiding this comment.
I am concerned that some of the new classes might better be made to come from the java.ts code generator.
Please know that all classes that can be generated from the Zod schemas, as shown in the update-copilot-dependency workflow, should be generated there, rather than hand authored.
Please double check that none of these classes in the json package are better suited for java.ts code gen.
Good question — I investigated thoroughly. None of the four new classes are candidates for the codegen:
The hand-authored |
|
@brunoborges do you want to review the first Agentic Sync since the code gen is introduced? |
There was a problem hiding this comment.
Pull request overview
Ports upstream github/copilot-sdk changes into the Java SDK, expanding session configuration and request capabilities (typed MCP servers, model capability overrides, per-turn/provider headers, and agent skill preloading) to stay API-parity with the reference implementation.
Changes:
- Add typed MCP server configuration (
McpServerConfig+ stdio/http subclasses) and update*Config/request DTOs to useMap<String, McpServerConfig>. - Add session/resume options for config discovery + sub-agent streaming event inclusion + model capability overrides, and wire them into request building.
- Add agent
skillspreloading and per-turn/provider request headers support; update/extend tests accordingly.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/github/copilot/sdk/SkillsTest.java | Adds coverage for per-agent skills injection behavior via snapshots. |
| src/test/java/com/github/copilot/sdk/McpAndAgentsTest.java | Migrates MCP tests to typed McpServerConfig APIs. |
| src/test/java/com/github/copilot/sdk/CopilotSessionTest.java | Removes hardcoded fake model to align with stricter CLI model validation. |
| src/test/java/com/github/copilot/sdk/ClosedSessionGuardTest.java | Removes hardcoded fake model to align with stricter CLI model validation. |
| src/main/java/com/github/copilot/sdk/json/SessionConfig.java | Adds new session options and types MCP servers as Map<String, McpServerConfig>. |
| src/main/java/com/github/copilot/sdk/json/SendMessageRequest.java | Adds requestHeaders field for per-turn headers on session.send. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java | Adds config discovery/sub-agent streaming/model capability overrides + typed MCP servers. |
| src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java | Adds config discovery/sub-agent streaming/model capability overrides + typed MCP servers. |
| src/main/java/com/github/copilot/sdk/json/ProviderConfig.java | Adds outbound provider headers map. |
| src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java | Introduces a named override type for model supports/limits (hand-authored). |
| src/main/java/com/github/copilot/sdk/json/MessageOptions.java | Adds per-turn requestHeaders and clones them safely. |
| src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java | Adds concrete stdio/local MCP server config DTO. |
| src/main/java/com/github/copilot/sdk/json/McpServerConfig.java | Adds polymorphic MCP server base type with type discriminator. |
| src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java | Adds concrete HTTP/SSE MCP server config DTO. |
| src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java | Adds typed MCP servers and skills preload list for agents. |
| src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java | Wires new create-session request fields (capabilities, discovery, sub-agent streaming, typed MCP). |
| src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java | Propagates new config fields into create/resume request payloads. |
| src/main/java/com/github/copilot/sdk/CopilotSession.java | Adds setModel overload that accepts model capability overrides; wires per-turn headers into send request. |
| .lastmerge | Advances recorded upstream sync commit. |
Copilot's findings
- Files reviewed: 19/19 changed files
- Comments generated: 2
| generatedCapabilities = new SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities(supports, | ||
| null); |
There was a problem hiding this comment.
CopilotSession#setModel(String, String, ModelCapabilitiesOverride) only maps modelCapabilities.supports into the generated SessionModelSwitchToParamsModelCapabilities and always passes limits as null. This means token limit overrides (and any future limits fields) provided by callers are silently ignored when switching models, despite ModelCapabilitiesOverride supporting them and the Javadoc implying they apply. Map ModelCapabilitiesOverride.getLimits() into SessionModelSwitchToParamsModelCapabilitiesLimits (converting Integer to Double as needed) and pass it into the generated capabilities record so model switches honor limit overrides too.
| generatedCapabilities = new SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities(supports, | |
| null); | |
| SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities.SessionModelSwitchToParamsModelCapabilitiesLimits limits = null; | |
| if (modelCapabilities.getLimits() != null) { | |
| limits = new ObjectMapper().convertValue(modelCapabilities.getLimits(), | |
| SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities.SessionModelSwitchToParamsModelCapabilitiesLimits.class); | |
| } | |
| generatedCapabilities = new SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities(supports, | |
| limits); |
There was a problem hiding this comment.
Fixed in def5449. Now maps modelCapabilities.getLimits() into SessionModelSwitchToParamsModelCapabilitiesLimits via ObjectMapper.convertValue() (handling the Integer→Double conversion) and passes it to the capabilities record instead of null.
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
There was a problem hiding this comment.
Import grouping in this file is inconsistent with the surrounding codebase (most files place java.* imports before third-party com.* imports). Consider moving the java.util.* imports above the Jackson imports to match the prevailing convention and avoid churn if an import organizer is applied later.
| import com.fasterxml.jackson.annotation.JsonInclude; | |
| import com.fasterxml.jackson.annotation.JsonProperty; | |
| import java.util.Collections; | |
| import java.util.Map; | |
| import java.util.Collections; | |
| import java.util.Map; | |
| import com.fasterxml.jackson.annotation.JsonInclude; | |
| import com.fasterxml.jackson.annotation.JsonProperty; |
There was a problem hiding this comment.
Fixed in def5449. Moved java.* imports above the Jackson com.* imports in ProviderConfig.java.
Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/c48ff7e5-7e42-43e6-a3df-42fe0004aa91 Co-authored-by: edburns <75821+edburns@users.noreply.github.com>
Ports 41 new commits from the official
github/copilot-sdkreference implementation into the Java SDK, updating the API to match the latest feature set.Before the change?
SessionConfig/ResumeSessionConfighad no way to override model capabilities, control sub-agent streaming events, or enable config discoveryMcpServerstyped asMap— no type safetyCustomAgentConfighad noskillsfield for per-agent skill preloadingProviderConfighad noheadersfield;MessageOptionshad norequestHeadersfor per-turn headersCopilotSession.setModel()had no overload accepting capability overrides.lastmergepointed toc3fa6cbfb83d4a20b7912b1a17013d48f5a277a1After the change?
New types (hand-authored in
jsonpackage — not candidates forjava.tscodegen):McpServerConfig— abstract base with typed subclassesMcpStdioServerConfig(local/stdio) andMcpHttpServerConfig(remote HTTP/SSE);McpServersis nowMap. ThemcpServersfield is absent fromapi.schema.json, so these cannot be generated.ModelCapabilitiesOverride— per-property overrides for model capabilities (vision, reasoning effort, token limits). WhilemodelCapabilitiesappears inapi.schema.jsonundersession.model.switchTo.params, the codegen already generates it as the verbose inner recordSessionModelSwitchToParamsModelCapabilities. A hand-authored class is required becausesession.createandsession.resumeare not in the schema, and the codegen has no mechanism to emit standalone named types shared across hand-authored request classes.API additions on
SessionConfig/ResumeSessionConfig:setModelCapabilities(ModelCapabilitiesOverride)— deep-merged over runtime defaultssetIncludeSubAgentStreamingEvents(Boolean)— suppress/expose streaming deltas from sub-agentssetEnableConfigDiscovery(Boolean)— auto-discover MCP configs and skill dirs from working dirOther additions:
CustomAgentConfig.setSkills(List)— preload named skill content into the agent's contextProviderConfig.setHeaders(Map)— custom headers on outbound provider requests; imports reordered to placejava.*beforecom.*per codebase conventionMessageOptions.setRequestHeaders(Map)— per-turn headers on model requestsCopilotSession.setModel(String, String, ModelCapabilitiesOverride)— new overload; now correctly maps bothsupportsandlimitsfromModelCapabilitiesOverrideinto the generated params (includingInteger→Doubleconversion for limit fields), so token limit overrides are properly honored when switching modelsExample — disable vision for a session then re-enable on model switch:
Example — per-agent skills with typed MCP server:
Test updates:
McpAndAgentsTestmigrated to typedMcpStdioServerConfigAPISkillsTest— added tests for per-agent skill injection (skillsfield)setModel("fake-test-model")fromCopilotSessionTest/ClosedSessionGuardTest— the new CLI validates model availability against the/modelslist.lastmergeupdated to922959f4a7b83509c3620d4881733c6c5677f00cPull request checklist
mvn spotless:applyhas been run to format the codemvn clean verifypasses locallyDoes this introduce a breaking change?