Skip to content

feat: Stream Events v2, tool builders, run/run_and_wait split (0.1.6)#11

Open
AjayaRamachandran wants to merge 3 commits into
mainfrom
coop-sdk-fixes
Open

feat: Stream Events v2, tool builders, run/run_and_wait split (0.1.6)#11
AjayaRamachandran wants to merge 3 commits into
mainfrom
coop-sdk-fixes

Conversation

@AjayaRamachandran
Copy link
Copy Markdown

  • 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.

AjayaRamachandran and others added 3 commits May 1, 2026 14:59
- 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>
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.

1 participant