Skip to content

Conversation

@SteveSandersonMS
Copy link
Contributor

@SteveSandersonMS SteveSandersonMS commented Jan 15, 2026

Summary

Adds a new sendAndWait() method to all SDK languages that waits for the agent turn to complete. This accompanies
the CLI change in https://github.com/github/copilot-agent-runtime/pull/1539 which makes send() return immediately
instead of blocking.

Changes

New API: sendAndWait()

All SDKs now have a method that sends a message and waits for session.idle:

Language Method Return Type Default Timeout
Node.js sendAndWait(options, timeout?) Promise<AssistantMessageEvent> 60s
.NET SendAndWaitAsync(options, timeout?, ct?) Task<AssistantMessageEvent?> 60s
Go SendAndWait(options, timeout) (*SessionEvent, error) 60s
Python send_and_wait(options, timeout?) SessionEvent 60s

All implementations:

  • Return the last assistant.message event received before session.idle
  • Handle session.error events by throwing/returning an error
  • Support configurable timeout (default 60 seconds)

Snapshot Test Infrastructure

Added protection against snapshot corruption on test failures.

Updated E2E Tests

All e2e tests updated to use sendAndWait() instead of send() + getFinalAssistantMessage().

Backward Compatibility

  • Old SDK + New CLI: Works (old send() still works, just returns faster)
  • New SDK + Old CLI: Works (old CLI blocks anyway)

Related

@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/send-nonblocking branch from e6ebae2 to bfbc4bd Compare January 15, 2026 23:08
@SteveSandersonMS
Copy link
Contributor Author

E2E tests will fail until the CLI is updated to a build that supports this

@SteveSandersonMS SteveSandersonMS marked this pull request as ready for review January 16, 2026 00:19
@SteveSandersonMS SteveSandersonMS requested a review from a team as a code owner January 16, 2026 00:19
Copilot AI review requested due to automatic review settings January 16, 2026 00:19
Copy link

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 a new sendAndWait() method across all SDK languages (Node.js, Python, Go, .NET) that sends a message and blocks until the agent turn completes. This accompanies a CLI change that makes send() non-blocking. The PR also adds snapshot test infrastructure protection to prevent snapshot corruption on test failures.

Changes:

  • Implements sendAndWait() method in all four SDK languages with consistent behavior (60s default timeout, returns final assistant message)
  • Updates all E2E tests to use sendAndWait() instead of send() + helper methods
  • Adds snapshot corruption protection by skipping snapshot writes when tests fail

Reviewed changes

Copilot reviewed 48 out of 51 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/copilot/session.py Adds send_and_wait() method that waits for session.idle
nodejs/src/session.ts Adds sendAndWait() method with AssistantMessageEvent return type
go/session.go Adds SendAndWait() method with timeout parameter
dotnet/src/Session.cs Adds SendAndWaitAsync() with TimeSpan timeout
python/e2e/conftest.py Adds test failure tracking to avoid corrupting snapshots
nodejs/test/e2e/harness/sdkTestContext.ts Tracks test failures to skip snapshot writes
go/e2e/testharness/context.go Passes test failure status to proxy stop
dotnet/test/Harness/E2ETestContext.cs Uses CI environment variable to skip snapshot writes
test/harness/replayingCapiProxy.ts Supports skipWritingCache query parameter
python/e2e/testharness/proxy.py Adds skip_writing_cache parameter to stop method
go/e2e/testharness/proxy.go Adds StopWithOptions method for conditional snapshot writes
dotnet/test/Harness/CapiProxy.cs Adds skipWritingCache parameter to StopAsync
python/e2e/test_session.py Updates tests to use send_and_wait
nodejs/test/e2e/session.test.ts Updates tests to use sendAndWait, adds new blocking behavior tests
go/e2e/session_test.go Updates tests to use SendAndWait
dotnet/test/SessionTests.cs Updates tests to use SendAndWaitAsync, adds blocking behavior tests
nodejs/examples/basic-example.ts Updates example to use sendAndWait
nodejs/README.md Documents new sendAndWait method
test/snapshots/* Updated snapshots reflecting minor model output variations

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

@SteveSandersonMS
Copy link
Contributor Author

Closing in favour of #27 and #28

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