8000 feat: Infinite Sessions by jmoseley · Pull Request #76 · github/copilot-sdk · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@jmoseley
Copy link
Contributor

Allow configuration of infinite sessions and compaction thresholds.

- Add InfiniteSessionConfig type with thresholds
- Add infiniteSessions option to SessionConfig
- Expose workspacePath on CopilotSession
- Pass config to server and capture workspace path in create/resume
- Add InfiniteSessionConfig TypedDict with thresholds
- Add infinite_sessions option to SessionConfig
- Expose workspace_path property on CopilotSession
- Convert snake_case to camelCase for wire format
- Add InfiniteSessionConfig struct with pointer fields for optional values
- Add InfiniteSessions field to SessionConfig
- Add WorkspacePath() method to Session
- Pass config in CreateSession and capture path in create/resume
- Add InfiniteSessionConfig class with threshold properties
- Add InfiniteSessions property to SessionConfig
- Add WorkspacePath property to CopilotSession
- Pass config in CreateSessionAsync and capture path in create/resume
- Add InfiniteSessionConfig documentation to SessionConfig options
- Document workspacePath property on CopilotSession
- Add Infinite Sessions section with examples for each SDK
- Document compaction events
@jmoseley jmoseley requested a review from a team as a code owner January 21, 2026 22:26
Copilot AI review requested due to automatic review settings January 21, 2026 22:26
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

This PR adds support for infinite sessions with automatic context compaction and workspace persistence across all language SDKs (Python, Node.js, Go, and .NET). Sessions can now automatically manage context window limits through background compaction and persist state to workspace directories.

Changes:

  • Added InfiniteSessionConfig type across all SDKs with configurable thresholds for background compaction and buffer exhaustion
  • Updated session objects to include workspace_path property that points to the session's persistent workspace directory
  • Modified create and resume session methods to accept infinite session configuration and return workspace paths
  • Added comprehensive documentation with usage examples for all supported languages

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
python/copilot/types.py Added InfiniteSessionConfig TypedDict and infinite_sessions field to SessionConfig
python/copilot/session.py Added workspace_path parameter and property to CopilotSession
python/copilot/client.py Updated create_session and resume_session to handle infinite sessions config and workspace path
python/README.md Added Infinite Sessions documentation section with Python examples
nodejs/src/types.ts Added InfiniteSessionConfig interface and infiniteSessions field to SessionConfig
nodejs/src/session.ts Added workspacePath parameter and getter to CopilotSession
nodejs/src/index.ts Exported InfiniteSessionConfig type
nodejs/src/client.ts Updated createSession and resumeSession to handle infinite sessions config and workspace path
nodejs/README.md Added Infinite Sessions documentation section with TypeScript examples
go/types.go Added InfiniteSessionConfig struct and InfiniteSessions field to SessionConfig
go/session.go Added workspacePath field and WorkspacePath() method to Session
go/client.go Updated CreateSession and ResumeSessionWithOptions to handle infinite sessions config and workspace path
go/README.md Added Infinite Sessions documentation section with Go examples
dotnet/src/Types.cs Added InfiniteSessionConfig class and InfiniteSessions property to SessionConfig
dotnet/src/Session.cs Added WorkspacePath parameter and property to CopilotSession
dotnet/src/Client.cs Updated CreateSessionAsync and ResumeSessionAsync to handle infinite sessions config and workspace path
dotnet/README.md Added Infinite Sessions documentation section with C# examples
Comments suppressed due to low confidence (1)

go/README.md:286

  • The function call references Float64(0.95) but should be copilot.Float64(0.95) to be consistent with the copilot.Bool(true) on line 284. This appears to be a missing package prefix.
        BufferExhaustionThreshold:     Float64(0.95), // Block at 95% until compaction completes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

patniko
patniko previously approved these changes Jan 22, 2026
friggeri
friggeri previously approved these changes Jan 22, 2026
Copy link
Collaborator
@friggeri friggeri left a comment

Choose a reason for hiding this comment

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

@jmoseley not going to block based on this, but please add e2e tests if you feel like that would be warranted for this feature

@jmoseley jmoseley dismissed stale reviews from friggeri and patniko via 40ffae5 January 23, 2026 00:54
- Test compaction triggers with low thresholds (0.5%/1%)
- Test session.usage_info events show token limits
- Test assistant.usage events
- Test no compaction events when infinite sessions disabled
The compaction trigger test requires real API calls to get realistic
token counts. The replay proxy doesn't provide the token usage data
needed for the CLI to trigger compaction.
The test requires a CLI build with infinite sessions support.
Run locally with COPILOT_CLI_PATH pointing to a local CLI build.
Add e2e tests for context compaction to Go, Python, and .NET SDKs:
- Test that compaction triggers with low thresholds and emits events
- Test that no compaction events occur when infinite sessions disabled
- Verify session still works after compaction (context preserved via summary)

These tests mirror the existing Node.js compaction tests.
Updates CLI dependency for Node.js SDK and shared test harness
to support protocol version 2 (infinite sessions).
@github-actions
Copy link

✅ Cross-SDK Consistency Review

I've reviewed this PR for consistency across all four SDK implementations (Node.js, Python, Go, and .NET), and I'm pleased to report that this PR maintains excellent cross-SDK consistency.

Summary

This PR adds infinite session configuration to all four SDKs, enabling automatic context compaction and workspace persistence. The feature is implemented consistently across all languages.

Detailed Analysis

✅ Type Definitions

All SDKs define the same InfiniteSessionConfig type with three fields:

  • Node.js: InfiniteSessionConfig with enabled, backgroundCompactionThreshold, bufferExhaustionThreshold
  • Python: InfiniteSessionConfig with enabled, background_compaction_threshold, buffer_exhaustion_threshold
  • Go: InfiniteSessionConfig with Enabled, BackgroundCompactionThreshold, BufferExhaustionThreshold
  • .NET: InfiniteSessionConfig with Enabled, BackgroundCompactionThreshold, BufferExhaustionThreshold (JSON names match Node.js via [JsonPropertyName] attributes)

✅ API Surface

All SDKs consistently:

  • Add infiniteSessions/infinite_sessions/InfiniteSessions to SessionConfig
  • Add workspacePath/workspace_path/WorkspacePath property to the Session class
  • Use the same default values (enabled: true, background: 0.80, buffer: 0.95)
  • Document the same behavior and workspace structure

✅ Documentation

All READMEs include:

  • Identical "Infinite Sessions" section with usage examples
  • Same compaction events documentation (session.compaction_start and session.compaction_complete)
  • Workspace path explanation
  • Examples for enabling, disabling, and customizing thresholds

✅ Testing

All SDKs include equivalent E2E tests:

  • CompactionTests.cs (.NET)
  • compaction_test.go (Go)
  • compaction.test.ts (Node.js)
  • test_compaction.py (Python)

Naming Convention Adherence

The PR correctly follows language-specific naming conventions:

  • Node.js/TypeScript: camelCase (e.g., backgroundCompactionThreshold)
  • Python: snake_case (e.g., background_compaction_threshold)
  • Go: PascalCase for exported fields (e.g., BackgroundCompactionThreshold)
  • .NET: PascalCase with JSON serialization attributes matching Node.js

Conclusion

This PR is an excellent example of maintaining feature parity across a multi-language SDK. No consistency issues were found. The implementation ensures users have the same capabilities and developer experience regardless of which SDK they choose.

Great work! 🎉

AI generated by SDK Consistency Review Agent

InfiniteSessions: &copilot.InfiniteSessionConfig{
Enabled: copilot.Bool(true),
BackgroundCompactionThreshold: copilot.Float64(0.80), // Start compacting at 80% context usage
BufferExhaustionThreshold: copilot.Float64(0.95), // Block at 95% until compaction completes

Choose a reason for hiding this comment

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

Inconsistency Issue: The copilot.Float64() helper function used here doesn't exist in the Go SDK.

The codebase has a copilot.Bool() helper in go/types.go:42 for creating bool pointers, but there's no equivalent Float64() helper for creating float64 pointers.

Recommended fix: Add a Float64 helper function to go/types.go:

// Float64 returns a pointer to the given float64 value.
// Use for setting threshold values: BackgroundCompactionThreshold: Float64(0.80)
func Float64(v float64) *float64 {
	return &v
}

Alternatively, update the README examples to show manual pointer creation without the helper function.

AI generated by SDK Consistency Review Agent for #76

@github-actions
Copy link

Cross-SDK Consistency Review ✅

Great work on implementing Infinite Sessions across all four SDK implementations! The feature parity and consistency are excellent overall.

✅ What's Consistent

  • API Design: All SDKs properly implement InfiniteSessionConfig with three properties (enabled, backgroundCompactionThreshold, bufferExhaustionThreshold)
  • Session Properties: workspacePath property added consistently to all session objects
  • Naming Conventions: Properly adapted to each language (camelCase for TS/JS, snake_case for Python, PascalCase for Go/C#)
  • Documentation: All four READMEs include comprehensive Infinite Sessions sections with language-appropriate examples
  • Tests: Compaction tests added to all SDKs (CompactionTests.cs, compaction_test.go, compaction.test.ts, test_compaction.py)
  • Response Handling: Both createSession and resumeSession updated to return workspacePath in all languages

⚠️ Issue Found

Go SDK: The README documentation uses copilot.Float64() helper function (lines 309-310) that doesn't exist in the codebase. See inline comment for details and suggested fix.

Summary

This PR maintains excellent cross-SDK consistency with language-appropriate conventions. Once the missing Go helper function is addressed, the implementations will be fully aligned.

AI generated by SDK Consistency Review Agent

The compaction tests require the shared test harness proxy, which has
timing issues on Windows CI causing TimeoutException during fixture
initialization. Tests pass on macOS and Ubuntu.
@github-actions
Copy link

✅ Cross-SDK Consistency Review: Infinite Sessions Feature

I've reviewed PR #76 for consistency across all four SDK implementations (Node.js, Python, Go, and .NET). Overall, this is an excellent example of consistent multi-language SDK development! 🎉

Summary

The infinite sessions feature has been implemented consistently across all four SDKs with:

  • ✅ Identical configuration parameters (enabled, backgroundCompactionThreshold, bufferExhaustionThreshold)
  • ✅ Consistent default values (0.80 and 0.95)
  • ✅ Proper language-idiomatic naming conventions
  • ✅ Complete documentation in all READMEs
  • ✅ Comprehensive test coverage in all SDKs
  • ✅ Proper serialization to camelCase for wire protocol

Language Convention Compliance

The naming follows proper conventions for each language:

  • Node.js/TypeScript: infiniteSessions, backgroundCompactionThreshold (camelCase ✅)
  • Python: infinite_sessions, background_compaction_threshold (snake_case ✅)
  • Go: InfiniteSessions, BackgroundCompactionThreshold (PascalCase ✅)
  • .NET: InfiniteSessions, BackgroundCompactionThreshold (PascalCase ✅)

All serialize correctly to camelCase for CLI communication.

Minor Documentation Enhancement Suggestions

  1. Python & Go READMEs: Consider adding explicit mention that resumeSession() populates the workspace_path/WorkspacePath property (like Node.js and .NET already do).

  2. Test Coverage Gap: None of the SDKs currently test the workspacePath property. Consider adding a test that verifies it's populated when infinite sessions are enabled and null/undefined when disabled.

  3. .NET CI Issue: Tests are marked as skipped due to "proxy startup timing issues" on Windows CI. This is unrelated to this PR but worth noting for future work.

Conclusion

This PR maintains excellent consistency across all SDK implementations. The feature is well-documented, properly tested, and follows each language's idioms correctly. No blocking issues found! 🚀

AI generated by SDK Consistency Review Agent

The CompactionTests class was causing the E2ETestFixture to fail
initialization on Windows, which cascaded to other test classes.
Removing the tests to unblock CI - the compaction feature is still
tested via Node.js, Go, and Python SDKs.
@github-actions
Copy link

✅ Cross-SDK Consistency Review

I've completed a comprehensive review of PR #76 for cross-language SDK consistency. Excellent work! This PR demonstrates outstanding attention to maintaining feature parity across all four SDK implementations.

🎯 What Was Changed

This PR adds Infinite Sessions functionality with automatic context compaction and workspace persistence across all SDKs:

  1. New InfiniteSessionConfig type with three fields:

    • enabled - Enable/disable infinite sessions (default: true)
    • backgroundCompactionThreshold - When to start background compaction (default: 0.80)
    • bufferExhaustionThreshold - When to block until compaction completes (default: 0.95)
  2. New workspacePath/WorkspacePath property on Session class

    • Returns path to workspace directory when infinite sessions enabled
    • Returns null/undefined/empty string when disabled
  3. Two new session events:

    • session.compaction_start / SessionCompactionStart
    • session.compaction_complete / SessionCompactionComplete

✨ Consistency Highlights

API Design Consistency ✅

All SDKs follow proper language conventions:

  • TypeScript: infiniteSessions, workspacePath, backgroundCompactionThreshold (camelCase)
  • Python: infinite_sessions, workspace_path, background_compaction_threshold (snake_case)
  • Go: InfiniteSessions, WorkspacePath(), BackgroundCompactionThreshold (PascalCase for exported)
  • .NET: InfiniteSessions, WorkspacePath, BackgroundCompactionThreshold (PascalCase)

Feature Parity ✅

All SDKs implement:

  • InfiniteSessionConfig configuration type
  • ✅ Session workspace path property (properly exposed as getter/property)
  • ✅ Integration in CreateSession/create_session methods
  • ✅ Integration in ResumeSession/resume_session methods
  • ✅ Compaction event types

Test Coverage ✅

All SDKs include identical E2E tests:

  • ✅ Test with low thresholds to trigger compaction
  • ✅ Test that compaction events are emitted
  • ✅ Test that infinite sessions can be disabled
  • ✅ Test that no compaction events when disabled

Documentation ✅

All four SDK READMEs include:

  • ✅ "Infinite Sessions" section with examples
  • ✅ Default behavior explanation
  • ✅ Example: accessing workspace path
  • ✅ Example: custom thresholds
  • ✅ Example: disabling infinite sessions
  • ✅ Compaction events documentation

🎉 Summary

This PR is a model example of consistent multi-language SDK development. The feature is implemented uniformly across Node.js, Python, Go, and .NET with:

  • Semantically equivalent APIs respecting language idioms
  • Complete feature parity
  • Comprehensive test coverage
  • Thorough documentation

No consistency issues found. This PR maintains the high quality standards of the copilot-sdk repository. 🚀

AI generated by SDK Consistency Review Agent

Tests pass locally on macOS and the proxy timeout issue appears to be
unrelated to these specific tests. The ToolsTests fixture timeout
that was seen in CI is a pre-existing flaky issue on Windows.
@github-actions
Copy link

✅ Cross-SDK Consistency Review

I've reviewed this PR across all four SDK implementations (Node.js, Python, Go, and .NET) and I'm pleased to report excellent consistency! 🎉

Summary

This PR adds the "Infinite Sessions" feature with automatic context compaction and workspace persistence. The implementation is consistent across all four SDKs with appropriate language-specific naming conventions.

What's Consistent ✓

1. Core Configuration Type (InfiniteSessionConfig)
All SDKs implement the same three properties:

  • enabled / Enabled (boolean, default: true)
  • backgroundCompactionThreshold / background_compaction_threshold / BackgroundCompactionThreshold (float, default: 0.80)
  • bufferExhaustionThreshold / buffer_exhaustion_threshold / BufferExhaustionThreshold (float, default: 0.95)

2. Session Integration

  • All SDKs add the config to their SessionConfig type
  • All SDKs add workspacePath / workspace_path / WorkspacePath property to session objects
  • Node.js: getter property workspacePath?: string
  • Python: property workspace_path: Optional[str]
  • Go: method WorkspacePath() string
  • .NET: property WorkspacePath?: string

3. Compaction Events
All SDKs emit the same two events:

  • session.compaction_start / SessionCompactionStartEvent / SESSION_COMPACTION_START
  • session.compaction_complete / SessionCompactionCompleteEvent / SESSION_COMPACTION_COMPLETE

4. Documentation

  • All READMEs include an "Infinite Sessions" section with examples
  • All show default behavior, custom thresholds, and how to disable
  • All document the workspace path structure
  • All document the compaction events

5. Testing
All SDKs include E2E tests covering:

  • Triggering compaction with low thresholds
  • Verifying compaction events are emitted
  • Verifying no events when disabled
  • Checking token removal and success status

Naming Conventions ✓

The naming follows proper language idioms:

  • TypeScript: camelCase (infiniteSessions, backgroundCompactionThreshold)
  • Python: snake_case (infinite_sessions, background_compaction_threshold)
  • Go: PascalCase for exported (InfiniteSessions, BackgroundCompactionThreshold)
  • .NET: PascalCase (InfiniteSessions, BackgroundCompactionThreshold)

Conclusion

This is a model example of how to implement a feature across multiple SDKs while maintaining consistency! The team has done an excellent job ensuring feature parity, following language conventions, and providing comprehensive documentation and tests. 👏

No consistency issues found. ✅

AI generated by SDK Consistency Review Agent

Windows CI has slower process startup times, especially when multiple
test classes initialize their fixtures in parallel. Increase the proxy
startup timeout from 10s to 30s on Windows to reduce flakiness.
@github-actions
Copy link

✅ Cross-SDK Consistency Review: EXCELLENT

This PR demonstrates exemplary consistency across all four SDK implementations. The "infinite sessions" feature has been implemented uniformly with proper attention to language idioms.

🎯 Consistency Analysis

API Design (All SDKs)

All four SDKs add the same configuration structure with identical semantics:

SDK Type Name Enabled Field Background Threshold Buffer Threshold
Node.js InfiniteSessionConfig enabled?: boolean backgroundCompactionThreshold?: number bufferExhaustionThreshold?: number
Python InfiniteSessionConfig enabled: bool background_compaction_threshold: float buffer_exhaustion_threshold: float
Go InfiniteSessionConfig Enabled *bool BackgroundCompactionThreshold *float64 BufferExhaustionThreshold *float64
.NET InfiniteSessionConfig Enabled bool? BackgroundCompactionThreshold double? BufferExhaustionThreshold double?

Defaults: All use 0.80 (80%) and 0.95 (95%) thresholds, enabled by default.

Naming Conventions

Proper language idioms are respected:

  • Node.js/Go/.NET: camelCase/PascalCase (backgroundCompactionThreshold)
  • Python: snake_case (background_compaction_threshold)
  • Wire protocol: Consistent camelCase in all SDKs

Session Properties

All SDKs expose workspace path:

  • Node.js: session.workspacePath (getter)
  • Python: session.workspace_path (property)
  • Go: session.WorkspacePath() (method)
  • .NET: session.WorkspacePath (property)

Event Consistency

Compaction events use consistent patterns:

  • Node.js: "session.compaction_start" / "session.compaction_complete"
  • Python: SessionEventType.SESSION_COMPACTION_START / SESSION_COMPACTION_COMPLETE
  • Go: SessionCompactionStart / SessionCompactionComplete
  • .NET: SessionCompactionStartEvent / SessionCompactionCompleteEvent

Documentation

All four README files include:

  • "Infinite Sessions" section with examples
  • Default values documented (0.80, 0.95)
  • Workspace path structure (~/.copilot/session-state/{sessionId}/)
  • Examples showing enabled/disabled/custom threshold configurations
  • Event descriptions

Test Coverage

All SDKs include compaction tests:

4D1C
  • dotnet/test/CompactionTests.cs
  • go/e2e/compaction_test.go
  • nodejs/test/e2e/compaction.test.ts
  • python/e2e/test_compaction.py

🏆 Summary

This is a model example of how to maintain feature parity across a multi-language SDK. No consistency issues found—excellent work!

AI generated by SDK Consistency Review Agent

@jmoseley jmoseley changed the title Enable Infinite Sessions feat: Infinite Sessions Jan 24, 2026

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
// Use longer timeout on Windows due to slower process startup
var timeoutSeconds = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 30 : 10;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The windows tests were flaking. Bumping up this timeout seems to stabilize things, but I'd love a second set of eyes @SteveSandersonMS

@jmoseley jmoseley enabled auto-merge January 24, 2026 16:18
@jmoseley jmoseley added this pull request to the merge queue Jan 24, 2026
Merged via the queue into main with commit 7a3dcf3 Jan 24, 2026
51 checks passed
@jmoseley jmoseley deleted the jm/infinite branch January 24, 2026 17:50
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.

6 participants

0