Skip to content

Fix E2E tests after runtime update#919

Merged
SteveSandersonMS merged 2 commits intomainfrom
stevesa/fix-test-after-runtime-upgrade
Mar 24, 2026
Merged

Fix E2E tests after runtime update#919
SteveSandersonMS merged 2 commits intomainfrom
stevesa/fix-test-after-runtime-upgrade

Conversation

@SteveSandersonMS
Copy link
Copy Markdown
Contributor

No description provided.

@SteveSandersonMS SteveSandersonMS requested a review from a team as a code owner March 24, 2026 21:56
Copilot AI review requested due to automatic review settings March 24, 2026 21:56
Copy link
Copy Markdown
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

Fixes the Node E2E “session start” assertion by making it resilient to additional non-session.start events being present in session.getMessages() immediately after session creation.

Changes:

  • Collects all session history events and filters down to session.start events before asserting shape/content.

@SteveSandersonMS SteveSandersonMS changed the title Fix session start test Fix E2E tests after runtime update Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Issue: Test Assumptions About Message Order

This PR fixes the Node.js E2E test to handle cases where session.start may not be the first event returned by getMessages(). However, the equivalent tests in Python, Go, and .NET still assume messages[0] is always session.start, which means they will likely fail with the same runtime update.

Issue Details

Node.js (✅ Fixed in this PR):

// Before: Assumed messages[0] is session.start
expect(await session.getMessages()).toMatchObject([...])

// After: Filters for session.start events
const allEvents = await session.getMessages();
const sessionStartEvents = allEvents.filter((e) => e.type === "session.start");
expect(sessionStartEvents).toMatchObject([...])

Python (❌ Needs similar fix):

# python/e2e/test_session.py:24-28
messages = await session.get_messages()
assert len(messages) > 0
assert messages[0].type.value == "session.start"  # ⚠️ Assumes messages[0] is session.start
assert messages[0].data.session_id == session.session_id

Go (❌ Needs similar fix):

// go/internal/e2e/session_test.go:33-40
messages, err := session.GetMessages(t.Context())
if len(messages) == 0 || messages[0].Type != "session.start" {  // ⚠️ Assumes messages[0] is session.start
    t.Fatalf("Expected first message to be session.start, got %v", messages)
}

.NET (❌ Needs similar fix):

// dotnet/test/SessionTests.cs:23-26
var messages = await session.GetMessagesAsync();
Assert.NotEmpty(messages);
var startEvent = Assert.IsType(SessionStartEvent)(messages[0]);  // ⚠️ Assumes messages[0] is session.start
Assert.Equal(session.SessionId, startEvent.Data.SessionId);

Recommended Action

To maintain cross-SDK consistency, apply equivalent fixes to Python, Go, and .NET test suites:

  1. Python: Filter get_messages() results for session.start events
  2. Go: Filter GetMessages() results for session.start type
  3. .NET: Find the SessionStartEvent in the messages list instead of assuming it's first

This pattern appears in multiple test methods across all SDKs (e.g., in concurrent session tests at Python line 167-170, Go resumed session tests around line 469).

Test Harness Change

The second change in this PR (returning 404 for non-chat-completion requests) is test infrastructure and doesn't affect API consistency. ✅

Generated by SDK Consistency Review Agent for issue #919 ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Generated by SDK Consistency Review Agent for issue #919


expect(await session.getMessages()).toMatchObject([
const allEvents = await session.getMessages();
const sessionStartEvents = allEvents.filter((e) => e.type === "session.start");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Good fix! This change makes the test robust to event ordering. The same pattern should be applied to Python, Go, and .NET tests - they currently assume messages[0] is always session.start, which will fail with the runtime update.

// Beyond this point, we're only going to be able to supply responses in CI if we have a snapshot,
// and we only store snapshots for chat completion. For anything else (e.g., custom-agents fetches),
// return 404 so the CLI treats them as unavailable instead of erroring.
if (options.requestOptions.path !== chatCompletionEndpoint) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change improves test harness behavior by returning 404 for non-chat-completion requests (e.g., custom-agents fetches) instead of erroring. This is test infrastructure and doesn't impact SDK API consistency. ✅

@SteveSandersonMS SteveSandersonMS merged commit 5b58582 into main Mar 24, 2026
26 checks passed
@SteveSandersonMS SteveSandersonMS deleted the stevesa/fix-test-after-runtime-upgrade branch March 24, 2026 22:12
@mc5455420269-jpg
Copy link
Copy Markdown

#919 (review)

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.

3 participants