Skip to content

Comments

Add SDK support for agent selection and session compaction APIs#544

Open
SteveSandersonMS wants to merge 3 commits intomainfrom
stevesa/sdk-agent-features
Open

Add SDK support for agent selection and session compaction APIs#544
SteveSandersonMS wants to merge 3 commits intomainfrom
stevesa/sdk-agent-features

Conversation

@SteveSandersonMS
Copy link
Contributor

@SteveSandersonMS SteveSandersonMS commented Feb 23, 2026

Summary

Add SDK support for the new agent selection and session compaction JSON-RPC APIs added to the Copilot CLI runtime.

New RPC APIs

Agent selection (session.agent.*):

  • list — List available custom agents
  • getCurrent — Get the currently selected agent
  • select — Select a custom agent by name
  • deselect — Deselect the current agent

Session compaction (session.compaction.*):

  • compact — Compact session history to reduce token usage

Changes

  • Code generation: Regenerated RPC types for all 4 SDKs (Node.js, Python, Go, .NET) from updated \�pi.schema.json\
  • C# codegen fix: Request class names now use the full RPC method path (e.g., \SessionAgentListRequest) to avoid name collisions between APIs that share method names like \list\
  • Snapshot normalization: Added \\ normalizer in the replaying CAPI proxy to keep compaction snapshots concise
  • E2E tests: Added 6 tests per language (24 total) covering all agent and compaction APIs

Test results

All 24 e2e tests pass across all 4 languages:

  • Node.js: 6/6 ✅
  • Python: 6/6 ✅
  • Go: 6/6 ✅
  • .NET: 6/6 ✅

Companion PR

Cannot merge or pass E2E tests until a corresponding runtime change (3538) is merged and an updated package is shipped.

SteveSandersonMS and others added 2 commits February 23, 2026 14:53
Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
… APIs

- Regenerate RPC types for Python, Go, and .NET from updated schema
- Add e2e tests for all 3 languages matching Node.js test patterns
- Fix C# codegen request class name collisions (use full RPC method path)
- Update dotnet/src/Generated/SessionEvents.cs and go/generated_session_events.go

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SteveSandersonMS SteveSandersonMS requested a review from a team as a code owner February 23, 2026 15:06
Copilot AI review requested due to automatic review settings February 23, 2026 15:06
@github-actions
Copy link

Cross-SDK Consistency Review ✅

I've reviewed PR #544 for consistency across all four SDK implementations (Node.js/TypeScript, Python, Go, and .NET). This PR demonstrates excellent cross-language consistency.

Summary

This PR adds two new RPC API families to all SDKs:

  • Agent Selection APIs (session.agent.*): list, getCurrent, select, deselect
  • Session Compaction API (session.compaction.compact): compact session history

✅ Consistency Findings

1. API Structure & Naming — Excellent consistency across all languages:

Language Access Pattern Method Names
Node.js session.rpc.agent.list() list(), getCurrent(), select(), deselect(), compact()
Python session.rpc.agent.list() list(), get_current(), select(), deselect(), compact()
Go session.RPC.Agent.List() List(), GetCurrent(), Select(), Deselect(), Compact()
.NET session.Rpc.Agent.ListAsync() ListAsync(), GetCurrentAsync(), SelectAsync(), DeselectAsync(), CompactAsync()

All naming follows the appropriate language conventions:

  • TypeScript: camelCase for methods ✅
  • Python: snake_case for methods ✅
  • Go: PascalCase for exported methods ✅
  • .NET: PascalCase with Async suffix ✅

2. Test Coverage — Complete parity:

All 4 SDKs include identical test scenarios (6 tests per language = 24 total):

Agent Selection tests:

  • should list available custom agents
  • should return null when no agent is selected
  • should select and get current agent
  • should deselect current agent
  • should return empty list when no custom agents configured

Compaction test:

  • should compact session history after messages

3. Generated Code — Consistent implementation:

All SDKs properly:

  • Generate RPC request/result classes from the schema
  • Expose agent/compaction APIs under session.rpc.*
  • Use the same underlying RPC method names ("session.agent.list", etc.)

4. C# Codegen Improvement — Good fix:

The change to use typeToClassName(method.rpcMethod) instead of methodName for request class names (e.g., SessionAgentListRequest instead of ListRequest) prevents naming collisions. This is a good defensive improvement that maintains consistency with the full RPC method path.

5. Test Infrastructure — Properly maintained:

  • Added snapshot normalization for compaction prompts in the replay proxy
  • All tests use the shared E2E test harness correctly
  • Snapshot files follow existing patterns

🎯 Conclusion

No consistency issues found. This PR maintains excellent feature parity across all four SDK implementations. The APIs are semantically identical, with only appropriate language-specific naming adaptations. Great work! 🚀

AI generated by SDK Consistency Review Agent

Copy link
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 cross-SDK support (Node.js, Python, Go, .NET) for new Copilot CLI JSON-RPC APIs covering agent selection (session.agent.*) and session compaction (session.compaction.*), along with replay-proxy normalization and new E2E coverage.

Changes:

  • Regenerates RPC types across SDKs and extends session-scoped RPC clients with agent and compaction APIs.
  • Updates C# codegen to avoid request-type name collisions by using full RPC method paths in request class names.
  • Adds/updates replay-proxy normalization and YAML snapshots, plus new E2E tests for agent selection and compaction RPCs.

Reviewed changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/snapshots/compaction/should_trigger_compaction_with_low_threshold_and_emit_events.yaml Updates compaction snapshot to use ${compaction_prompt} and refreshes expected conversation flow.
test/snapshots/agent_and_compact_rpc/should_compact_session_history_after_messages.yaml New snapshot covering session.compaction.compact RPC flow.
test/harness/replayingCapiProxy.ts Normalizes the verbose compaction-summary prompt into ${compaction_prompt} for stable snapshots.
scripts/codegen/csharp.ts Uses full RPC method path for generated C# request class names to prevent collisions.
python/e2e/test_agent_and_compact_rpc.py Adds Python E2E tests for agent selection + compaction RPCs.
python/copilot/generated/rpc.py Adds generated Python RPC types + APIs for agent and compaction.
nodejs/test/e2e/agent_and_compact_rpc.test.ts Adds Node.js E2E tests for agent selection + compaction RPCs.
nodejs/src/generated/rpc.ts Adds generated Node session RPC bindings and types for agent and compaction.
go/rpc/generated_rpc.go Adds generated Go RPC types + Agent/Compaction RPC APIs on SessionRpc.
go/internal/e2e/agent_and_compact_rpc_test.go Adds Go E2E tests for agent selection + compaction RPCs.
dotnet/test/AgentAndCompactRpcTests.cs Adds .NET E2E tests for agent selection + compaction RPCs.
dotnet/src/Generated/Rpc.cs Adds generated .NET RPC types + APIs for agent and compaction, and updates request-type names.

Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link

✅ Cross-SDK Consistency Review: Excellent

I've reviewed this PR for consistency across all four SDK implementations (Node.js/TypeScript, Python, Go, and .NET), and I'm pleased to report that this change demonstrates exemplary cross-language parity.

What I Verified

1. API Methods

All 4 SDKs expose the same agent selection and session compaction APIs with language-appropriate naming:

Agent Selection APIs:

  • Node.js: session.rpc.agent.list(), getCurrent(), select(), deselect()
  • Python: session.rpc.agent.list(), get_current(), select(), deselect()
  • Go: session.RPC.Agent.List(), GetCurrent(), Select(), Deselect()
  • .NET: session.Rpc.Agent.ListAsync(), GetCurrentAsync(), SelectAsync(), DeselectAsync()

Session Compaction API:

  • Node.js: session.rpc.compaction.compact()
  • Python: session.rpc.compaction.compact()
  • Go: session.RPC.Compaction.Compact()
  • .NET: session.Rpc.Compaction.CompactAsync()

The naming follows each language's conventions (camelCase for JS, snake_case for Python, PascalCase for exported Go/C# identifiers).

2. Type Definitions

Generated RPC types are semantically equivalent across all languages:

  • SessionAgentListResult, SessionAgentGetCurrentResult, SessionAgentSelectResult, SessionAgentDeselectResult
  • SessionCompactionCompactResult with fields: success: boolean, tokensRemoved: number, messagesRemoved: number

All types properly handle nullable values (e.g., agent can be null in GetCurrent when no agent is selected).

3. E2E Test Coverage

All 4 SDKs have identical test scenarios (6 tests each, 24 total):

Agent Selection Tests:

  1. ✅ List available custom agents
  2. ✅ Return null when no agent is selected
  3. ✅ Select and get current agent
  4. ✅ Deselect current agent
  5. ✅ Return empty list when no custom agents configured

Compaction Test:
6. ✅ Compact session history after messages

Each test verifies the same behavior and assertions, ensuring feature parity.

4. Code Generation Improvements

  • C# codegen enhancement: Request classes use full RPC method paths (e.g., SessionAgentListRequest) to avoid name collisions
  • Nullable type handling: Proper anyOf: [T, null]T? mapping in C# codegen
  • All SDKs regenerated from the same api.schema.json source

Summary

This PR is a model example of maintaining cross-SDK consistency:

  • ✅ Complete feature parity across all 4 languages
  • ✅ Idiomatic naming following each language's conventions
  • ✅ Comprehensive E2E test coverage with parallel test scenarios
  • ✅ Proper code generation from shared schema definitions

No consistency issues found. The implementation maintains the high standard of this multi-language SDK repository.

Great work, @SteveSandersonMS! 🎉

AI generated by SDK Consistency Review Agent

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.

1 participant