-
Notifications
You must be signed in to change notification settings - Fork 28
Add sendAndWait API for all SDKs #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stevesa/e2e-infra-snapshots
Are you sure you want to change the base?
Add sendAndWait API for all SDKs #28
Conversation
There was a problem hiding this 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 ofsend()+ 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>` |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| ##### `sendAndWait(options: MessageOptions, timeout?: number): Promise<SessionEvent | undefined>` | |
| ##### `sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>` |
| .Where(e => e != null) | ||
| .ToList()!; |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
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.
| .Where(e => e != null) | |
| .ToList()!; | |
| .OfType<SessionEvent>() | |
| .ToList(); |
d82a2c3 to
40de300
Compare
f4f7d77 to
4a72d4c
Compare
40de300 to
f23a4ca
Compare
47a77e8 to
100748b
Compare
547b2ad to
2055997
Compare
100748b to
9d2188b
Compare
456dc7d to
4388a4e
Compare
9d2188b to
caf8cf9
Compare
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:
All implementations:
Updated E2E Tests
All e2e tests updated to use \sendAndWait()\ instead of \send()\ + \getFinalAssistantMessage().
Backward Compatibility
Related