Skip to content

Conversation

@SteveSandersonMS
Copy link
Contributor

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\ 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 \�ssistant.message\ event received before \session.idle\
  • Handle \session.error\ events by throwing/returning an error
  • Support configurable timeout (default 60 seconds)

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

Copilot AI review requested due to automatic review settings January 16, 2026 00:38
@SteveSandersonMS SteveSandersonMS requested a review from a team as a code owner January 16, 2026 00:38
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 to all SDK languages (Node.js, Python, Go, and .NET) that sends a message and blocks until the agent turn completes. This accompanies a CLI change where send() now returns immediately instead of blocking.

Changes:

  • Implements sendAndWait() API across all four SDK languages with consistent 60-second default timeout behavior
  • Updates all e2e tests to use sendAndWait() instead of send() + helper functions
  • Adds forward compatibility for unknown event types in Python and .NET

Reviewed changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
nodejs/src/session.ts Implements sendAndWait() method with timeout and error handling
nodejs/src/index.ts Exports new AssistantMessageEvent type
nodejs/test/e2e/*.test.ts Updates tests to use sendAndWait() and adds new blocking behavior tests
nodejs/examples/basic-example.ts Updates example to use sendAndWait()
nodejs/README.md Documents new sendAndWait() API
python/copilot/session.py Implements send_and_wait() method
python/copilot/generated/session_events.py Adds forward compatibility for unknown event types
python/e2e/*.py Updates tests to use send_and_wait()
go/session.go Implements SendAndWait() method
go/e2e/*.go Updates tests to use SendAndWait()
dotnet/src/Session.cs Implements SendAndWaitAsync() method
dotnet/src/Generated/SessionEvents.cs Adds forward compatibility for unknown event types
dotnet/src/Client.cs Adds null check for unknown events
dotnet/test/*.cs Updates tests to use SendAndWaitAsync() and adds new blocking behavior tests
test/snapshots/session/*.yaml New test snapshots for blocking behavior tests
Comments suppressed due to low confidence (1)

nodejs/test/e2e/session.test.ts:1

  • The code accesses assistantMessages[assistantMessages.length - 1] without checking if the array is empty. If no assistant messages exist, this will throw an error. Add a check to ensure the array has at least one element before accessing it.
import { describe, expect, it, onTestFinished } from "vitest";

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


Returns the message ID.

##### `sendAndWait(options: MessageOptions, timeout?: number): Promise<SessionEvent | undefined>`
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The return type documentation is inconsistent with the actual implementation. The method returns Promise<AssistantMessageEvent | undefined> but the documentation states Promise<SessionEvent | undefined>. This should be corrected to Promise<AssistantMessageEvent | undefined> to match the implementation and provide more precise type information.

Suggested change
##### `sendAndWait(options: MessageOptions, timeout?: number): Promise<SessionEvent | undefined>`
##### `sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>`

Copilot uses AI. Check for mistakes.
Comment on lines +345 to +346
.Where(e => e != null)
.ToList()!;
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The use of the null-forgiving operator ! after ToList() is potentially unsafe. While the .Where(e => e != null) filters out nulls, the compiler doesn't recognize this pattern. Consider using .OfType<SessionEvent>() instead of .Where(e => e != null) to properly narrow the type, eliminating the need for the null-forgiving operator.

Suggested change
.Where(e => e != null)
.ToList()!;
.OfType<SessionEvent>()
.ToList();

Copilot uses AI. Check for mistakes.
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/e2e-infra-snapshots branch 3 times, most recently from d82a2c3 to 40de300 Compare January 16, 2026 00:48
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/send-nonblocking-v2 branch from f4f7d77 to 4a72d4c Compare January 16, 2026 00:48
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/e2e-infra-snapshots branch from 40de300 to f23a4ca Compare January 16, 2026 00:49
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/send-nonblocking-v2 branch 3 times, most recently from 47a77e8 to 100748b Compare January 16, 2026 00:55
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/e2e-infra-snapshots branch from 547b2ad to 2055997 Compare January 16, 2026 00:59
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/send-nonblocking-v2 branch from 100748b to 9d2188b Compare January 16, 2026 01:00
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/e2e-infra-snapshots branch 2 times, most recently from 456dc7d to 4388a4e Compare January 16, 2026 01:06
@SteveSandersonMS SteveSandersonMS force-pushed the stevesa/send-nonblocking-v2 branch from 9d2188b to caf8cf9 Compare January 16, 2026 01:07
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