Skip to content

[SDK] Enhance timeout controls + reporting#1586

Merged
chelojimenez merged 1 commit intomainfrom
sdk-graceful-early-exit
Mar 11, 2026
Merged

[SDK] Enhance timeout controls + reporting#1586
chelojimenez merged 1 commit intomainfrom
sdk-graceful-early-exit

Conversation

@chelojimenez
Copy link
Contributor

@chelojimenez chelojimenez commented Mar 11, 2026


Note

Medium Risk
Changes core eval runtime behavior (timeouts/abort propagation and tool execution short-circuiting), which could affect test outcomes and reporting semantics, but is scoped to the SDK and covered by new unit tests.

Overview
Enhances SDK timeout + early-exit controls for evals. PromptOptions now supports abortSignal, timeoutMs, and stopAfterToolCall (stop after a named tool is selected, stub its result, and still capture tool name/args).

Improves timeout behavior and reporting. EvalTest iterations now enforce timeouts by aborting the active prompt and allowing a 1s grace period before hard-failing, while aggregating whatever prompt history, tokens, and latencies were captured. TestAgent now preserves partial messages/tool calls/token usage when prompts are aborted/timeout, and skips MCP widget snapshot capture for short-circuited tools.

Docs and sdk/README.md are updated to describe the new options and clarify timeoutMs semantics; tests add coverage for partial-timeout success, multi-turn metric preservation, abort handling, stopAfterToolCall, and the new timeout/abort passthroughs.

Written by Cursor Bugbot for commit 6f82805. This will update automatically on new commits. Configure here.

@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Mar 11, 2026
@chelojimenez
Copy link
Contributor Author

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@dosubot dosubot bot added the enhancement New feature or request label Mar 11, 2026
@chelojimenez chelojimenez merged commit bfa55cb into main Mar 11, 2026
6 of 8 checks passed
@chelojimenez chelojimenez deleted the sdk-graceful-early-exit branch March 11, 2026 18:39
@MCPJam MCPJam deleted a comment from coderabbitai bot Mar 11, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

toolName: toolCall.toolName,
arguments: (toolCall.input ?? {}) as Record<string, unknown>,
}))
);
Copy link

Choose a reason for hiding this comment

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

Unguarded stepResult.toolCalls access may crash on unexpected shape

Low Severity

The onStepFinish callback accesses stepResult.toolCalls.map(...) without a defensive null/array check. The existing extractToolCalls in tool-extraction.ts defensively guards the same property with step.toolCalls && Array.isArray(step.toolCalls). If the AI SDK ever delivers a step result with a missing or non-array toolCalls (e.g. during an abort or error mid-step), this would throw a TypeError inside the generateText call, potentially masking the real error and losing partial results that the PR is specifically trying to preserve.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant