-
Notifications
You must be signed in to change notification settings - Fork 682
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
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.
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
4388a4e to
a885cdd
Compare
2cf821d to
c79a12c
Compare
c79a12c to
b8b760b
Compare
429a257 to
d270072
Compare
* Add support release documents * Clean up SUPPORT.md * Update CODEOWNERS to use wildcard for ownership
Summary
Adds a new
sendAndWait()method to all SDK languages that waits for the agent turn to complete. This accompanies the CLI change which makessend()return immediately instead of blocking.Changes
New API:
sendAndWait()All SDKs now have a method that sends a message and waits for
session.idle:sendAndWait(options, timeout?)Promise<AssistantMessageEvent>SendAndWaitAsync(options, timeout?, ct?)Task<AssistantMessageEvent?>SendAndWait(options, timeout)(*SessionEvent, error)send_and_wait(options, timeout?)SessionEventAll implementations:
assistant.messageevent received beforesession.idlesession.errorevents by throwing/returning an errorUpdated E2E Tests
All e2e tests updated to use
sendAndWait()instead ofsend()+getFinalAssistantMessage().Backward Compatibility
send()still works, just returns faster)Related