Skip to content

feat(stream): return StreamResult from stream helpers; fix _compat SyntaxError#46

Open
windsornguyen wants to merge 3 commits intonextfrom
feat/stream-result
Open

feat(stream): return StreamResult from stream helpers; fix _compat SyntaxError#46
windsornguyen wants to merge 3 commits intonextfrom
feat/stream-result

Conversation

@windsornguyen
Copy link
Member

Pull Request

Linear Issue

N/A

Summary

What:

stream_async and stream_sync now accumulate content and tool-call deltas into a StreamResult dataclass and return it instead of None. A shared accumulate_tool_call() function is extracted so both the stream helpers and DedalusRunner use the same logic. Also fixes a duplicate by_alias keyword arg SyntaxError in _compat.py that broke Python 3.9.

Why:

Streaming callers previously had no way to programmatically access accumulated content or tool calls after a stream completed — the helpers were fire-and-forget printers. The _compat.py bug blocked all test execution on Python 3.9.

Lines added: ~0 net (+774 / −778 — mostly test style normalization)

Test Plan

  • uv run pytest tests/test_stream_helpers.py — 14 tests covering content accumulation, incremental tool-call reassembly (including thought_signature, parallel calls), empty streams, and result independence.
  • uv run pytest tests/test_encryption.py tests/test_mcp_wire.py tests/test_mcp_wire_connections.py tests/test__bug_report.py tests/test_local_scheduler.py — 85 existing hand-written tests still pass after style refactor.

Repro / Showcase

N/A — no UI change. The _compat.py fix is verified by successfully importing dedalus_labs on Python 3.9.

Tests Added

  • Unit tests
  • Integration tests
  • E2E tests
  • N/A (no new code paths)

Documentation

  • Internal (docs/): N/A
  • External (apps/docs/): N/A

Reviewers

  • Domain: @
  • Readability: @

Notes for Reviewers

Three commits:

  1. fix(_compat) — one-line deletion of duplicate by_alias=True
  2. feat(stream)StreamResult, accumulate_tool_call, updated helpers, DRY refactor of DedalusRunner, new tests
  3. style(tests) — flatten class-based tests to module-level functions across 4 files

The feature commit changes the return type of stream_async / stream_sync from None to StreamResult. Callers that were ignoring the return value are unaffected.

Changelog

[2025-02-10]

Feedback received:

  • (none yet)

Changes made:

  • Initial implementation

Stainless regen (2026-02-07) added `by_alias=by_alias` but a manually
added `by_alias=True` from Nov 2025 was still present. Duplicate keyword
arguments are a SyntaxError on Python 3.9.
stream_async and stream_sync now accumulate content and tool-call deltas
into a StreamResult dataclass and return it. The accumulation logic is
extracted into a shared accumulate_tool_call() function that
DedalusRunner.core also delegates to (DRY).

Exports StreamResult and accumulate_tool_call from dedalus_labs.utils.stream.
Adds tests covering content, tool-call reassembly, thought_signature,
parallel calls, empty streams, and result independence.
Standardise hand-written test files (test_encryption, test_mcp_wire,
test_mcp_wire_connections, test__bug_report) to match the module-level
function style used in test_local_scheduler. Replaces class wrappers and
multi-line banners with single-line section comments.
@cursor
Copy link

cursor bot commented Feb 10, 2026

PR Summary

Medium Risk
Changes public helper return types and centralizes streaming tool-call reconstruction used by the runner, which could affect downstream streaming consumers despite added unit coverage.

Overview
Streaming helpers now return structured results. stream_async/stream_sync still print tokens as they arrive, but now also accumulate full text plus reassembled tool-call deltas into a returned StreamResult.

Tool-call delta reassembly was extracted into shared accumulate_tool_call() and DedalusRunner was updated to use it, reducing duplicated streaming logic. Separately, _compat.model_dump() removes a duplicate by_alias argument that caused a Python 3.9 SyntaxError. Tests were heavily refactored for style and a new test_stream_helpers.py suite was added to cover the new stream behavior.

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

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