Skip to content

feat: add model field to CustomAgentConfig across all SDKs#1309

Merged
patniko merged 10 commits into
mainfrom
patniko/custom-agent-model
May 15, 2026
Merged

feat: add model field to CustomAgentConfig across all SDKs#1309
patniko merged 10 commits into
mainfrom
patniko/custom-agent-model

Conversation

@patniko
Copy link
Copy Markdown
Contributor

@patniko patniko commented May 15, 2026

Summary

Add an optional model property to CustomAgentConfig in all five SDKs (Node/TS, Python, Go, .NET, Rust). This closes the gap between the runtime's SweCustomAgent.model support and the SDK's public API.

Motivation

The runtime already supports per-subagent model selection via YAML frontmatter in .github/agents/*.md files, but the programmatic SDK API (customAgents array in session config) did not expose this capability. Users who define agents programmatically could not specify which model an agent should use.

Changes

Each SDK gets its own commit for easy review:

  • Node/TS (nodejs/src/types.ts): model?: string on CustomAgentConfig interface — passed through directly to wire format
  • Python (python/copilot/session.py + client.py): model: NotRequired[str] on CustomAgentConfig TypedDict + wire format conversion
  • Go (go/types.go): Model string field with json:"model,omitempty" tag
  • .NET (dotnet/src/Types.cs): string? Model property with [JsonPropertyName("model")]
  • Rust (rust/src/types.rs): model: Option<String> field + with_model() builder method

Behavior

When set, the runtime will attempt to use the specified model for the agent, falling back to the parent session model if unavailable. When omitted/null, the agent inherits the session's model (existing behavior, no breaking change).

Validation

All five SDKs compile successfully: npx tsc --noEmit, python3 -c "import copilot", go build ./..., dotnet build, cargo check --all-features.

patniko and others added 5 commits May 15, 2026 14:56
Add optional `model` property to the Node/TypeScript CustomAgentConfig
interface. When set, the runtime will attempt to use the specified model
for the agent, falling back to the parent session model if unavailable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add optional `model` key to the Python CustomAgentConfig TypedDict and
wire it through `_convert_custom_agent_to_wire_format` so the runtime
receives it in the session.create / session.resume payloads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add optional `Model` field to the Go CustomAgentConfig struct. The field
serializes as `"model"` and is omitted when empty. When set, the runtime
will attempt to use the specified model for the agent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add optional `Model` property to the .NET CustomAgentConfig class. The
property serializes as `"model"` and is omitted when null. When set,
the runtime will attempt to use the specified model for the agent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add optional `model` field to the Rust CustomAgentConfig struct with a
`with_model` builder method. Serializes as `"model"` (camelCase
rename is a no-op for single-word fields) and is skipped when None.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 15, 2026 21:59
@patniko patniko requested a review from a team as a code owner May 15, 2026 21:59
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.

Pull request overview

Adds support for per-custom-agent model selection across all SDKs by exposing an optional model field on CustomAgentConfig and ensuring Python maps it into the wire payload.

Changes:

  • Added model to custom agent config types in Node/TS, Python, Go, .NET, and Rust.
  • Added Python wire-format forwarding for model.
  • Added a Rust with_model() builder method.
Show a summary per file
File Description
rust/src/types.rs Adds optional serialized model field and builder method.
python/copilot/session.py Adds model to the CustomAgentConfig TypedDict.
python/copilot/client.py Forwards model into custom agent wire format.
nodejs/src/types.ts Adds model to the TypeScript custom agent interface.
go/types.go Adds JSON-serialized Model field to Go custom agent config.
dotnet/src/Types.cs Adds JSON-serialized nullable Model property to .NET custom agent config.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 0

patniko and others added 2 commits May 15, 2026 15:02
Add a test case that creates a custom agent with a model property and
asserts it appears in the session.create RPC payload.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add unit tests asserting that the model key is correctly forwarded
to the camelCase wire payload, and omitted when not set.

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

This comment has been minimized.

patniko and others added 2 commits May 15, 2026 15:03
Add tests asserting that the model field round-trips through JSON when
set and is omitted from the payload when empty.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the SessionConfig clone test to set Model on a CustomAgentConfig
and assert it survives the clone operation.

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

This comment has been minimized.

Add unit tests for the with_model() builder, JSON serialization with
model set, and confirming model is omitted from wire when None.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@patniko patniko force-pushed the patniko/custom-agent-model branch from 223ee24 to a2f563f Compare May 15, 2026 22:19
@github-actions
Copy link
Copy Markdown
Contributor

✅ Cross-SDK Consistency Review

This PR adds the model field to CustomAgentConfig across all five SDK implementations. The changes are consistent and well-aligned:

SDK Type JSON key Optional behavior
Node.js/TS model?: string "model" Omitted when undefined
Python model: NotRequired[str] "model" Omitted from wire format when absent
Go Model string + omitempty "model" Omitted when zero value — consistent with other optional string fields (DisplayName, Description) in the same struct
.NET string? Model "model" Null-safe; Model = other.Model is included in the SessionConfig copy constructor
Rust pub model: Option<String> + with_model() builder "model" skip_serializing_if = "Option::is_none" — consistent with existing builder pattern (with_display_name, with_skills, etc.)

Documentation is uniform across all SDKs describing the runtime fallback behavior.

Tests cover both "field present" and "field absent/omitted" cases in every SDK.

No inconsistencies found. 🎉

Generated by SDK Consistency Review Agent for issue #1309 · ● 440.9K ·

Comment thread dotnet/src/Types.cs
@patniko patniko added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit d0eb531 May 15, 2026
43 checks passed
@patniko patniko deleted the patniko/custom-agent-model branch May 15, 2026 22:38
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.

3 participants