feat: Stream Events v2, tool builders, run/run_and_wait split (0.1.6)#11
Open
AjayaRamachandran wants to merge 3 commits into
Open
feat: Stream Events v2, tool builders, run/run_and_wait split (0.1.6)#11AjayaRamachandran wants to merge 3 commits into
AjayaRamachandran wants to merge 3 commits into
Conversation
- Split client.run (fire-and-forget) from client.run_and_wait (polling) (R18)
- Generic RunResult[T] for type-narrowed answers via Pydantic (R10, R13)
- Default headers / defaults options for FunctionTools at the client level (R9)
- ResourceTool, MCPTool.headers + MCPAuth, expanded Engine literal (R7, R17, R4)
- ReasoningNode.subtasks (plural), ToolUse, RunInput.images/resources/skills/agent_id (R1, R2, R3)
- Stream parser emits StartedEvent first, parses reasoning_node/tool_call/result/error frames (R8, R15, R5)
- New tools.{platform,function,mcp,resource} builders (R11)
- _normalize_tools auto-promotes function-tool defaults into JSON Schema parameters (R12)
- client.observe(run_id) for re-attaching to in-flight runs (R16)
25 tests pass. Requires API with Stream Events v2 support.
Co-authored-by: Cursor <cursoragent@cursor.com>
Restores options.await_completion as a deprecated alias so existing
docs snippets keep working without changes:
- RunOptions(await_completion: Optional[bool]) and RunParams.options
come back, both marked deprecated
- client.run(..., options={"await_completion": True}) routes through
run_and_wait() and emits a one-shot DeprecationWarning
- Both dict and dataclass forms of options accepted
- Refactored to a private _create_run_only() helper to break recursion
(run -> run_and_wait -> run -> ... loop)
Wire format: SSE parser now reads payload.get("runId") with a fallback
to payload.get("run_id"), and synthesizes StartedEvent for bare
{"runId": ...} frames. Canonical camelCase preferred; legacy
snake_case still parses.
ErrorCode spelling: cancelled -> canceled (one l, matches RunStatus).
README ErrorCode block updated.
README: new "Back-compat and deprecations" section documenting the
options.await_completion deprecation, runId canonical/legacy policy,
and canceled spelling.
Tests: All green. New tests cover the deprecation routing (dict and
dataclass forms), no-op options dict still fire-and-forgets, legacy
run_id snake_case still parses, and canceled error code on the wire.
Co-authored-by: Cursor <cursoragent@cursor.com>
Return the terminal run status and result metadata from stream generators so consumers do not see failed SSE streams as succeeded. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
25 tests pass. Requires API with Stream Events v2 support.