Skip to content

feat: streaming dep optional, non streaming path, streaming flag, rel… - #65

Merged
bobrykov merged 3 commits into
masterfrom
feat/non-streaming-path
Aug 2, 2026
Merged

feat: streaming dep optional, non streaming path, streaming flag, rel…#65
bobrykov merged 3 commits into
masterfrom
feat/non-streaming-path

Conversation

@bobrykov

@bobrykov bobrykov commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

…ease profile

@bobrykov

bobrykov commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3b59239-2aa7-46d7-8a22-7769c024d6cb

📥 Commits

Reviewing files that changed from the base of the PR and between 212f0dc and 65d133a.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • examples/chat.rs
  • src/engine/bare.rs
  • src/provider.rs
🚧 Files skipped from review as they are similar to previous changes (4)
  • examples/chat.rs
  • src/provider.rs
  • README.md
  • src/engine/bare.rs

📝 Walkthrough

Walkthrough

Changes

Turn execution and feature configuration

Layer / File(s) Summary
Feature configuration and gated APIs
Cargo.toml, src/capabilities.rs, src/stream.rs, src/managers.rs, src/provider.rs, src/reflection/llm.rs, src/engine/bare/...
Streaming dependencies and APIs are feature-gated. Provider, hook, tool-health, and schema-validation paths compile only when enabled.
Turn-mode dispatch and cancellation
src/engine/bare.rs
BareLoop supports TurnMode, non-streaming requests, cancellation, shared bookkeeping, and mode-aware dispatch.
Execution tests and streaming compatibility
src/engine/bare.rs, src/engine/bare/dispatch.rs
Mocks assemble non-streaming responses. Tests cover defaults, tool loops, cancellation, and feature-gated streaming behavior.
Example and release documentation
README.md, CHANGELOG.md, examples/chat.rs, src/observer.rs, src/stream/rate_limit.rs, src/structured.rs
The example selects turn mode at runtime. Documentation records feature requirements, turn paths, release changes, and corrected references.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant chat
  participant BareLoop
  participant ProviderClient
  User->>chat: Set NO_STREAM=1
  chat->>BareLoop: Set TurnMode::NonStreaming
  BareLoop->>ProviderClient: Send create_message request
  ProviderClient-->>BareLoop: Return assembled response
  BareLoop-->>chat: Return completed turn
  chat-->>User: Print assembled response
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: optional streaming support, a non-streaming path, and runtime streaming selection.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/non-streaming-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 5

🧹 Nitpick comments (3)
src/engine/bare.rs (2)

2708-2716: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename the test to match what it asserts.

turn_mode_default_is_nonstreaming_without_feature asserts both branches: NonStreaming without the feature and Streaming with it. The name describes only one branch.

📝 Proposed rename
-    fn turn_mode_default_is_nonstreaming_without_feature() {
+    fn turn_mode_default_follows_streaming_feature() {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engine/bare.rs` around lines 2708 - 2716, Rename the test function
turn_mode_default_is_nonstreaming_without_feature to reflect that it verifies
the default turn mode for both streaming and non-streaming feature
configurations. Keep the assertions and test behavior unchanged.

2469-2494: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared mock response assembly.

MockClient::create_message here and RecordingClient::create_message at lines 6062-6092 contain the same event-to-response assembly: pop queued events, track the last MessageDelta stop reason, feed each event to StreamAccumulator, then build the NonStreamingResponse. The two copies will drift as the accumulator contract evolves.

Extract one test helper, for example fn assemble_response(events: Vec<StreamEvent>) -> Result<NonStreamingResponse, ApiError>, and call it from both clients.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engine/bare.rs` around lines 2469 - 2494, Extract the duplicated
event-to-response logic from MockClient::create_message and
RecordingClient::create_message into a shared test helper such as
assemble_response. The helper should accept queued StreamEvent values, track the
latest MessageDelta stop reason, process events through StreamAccumulator, and
return the constructed NonStreamingResponse or ApiError; update both client
methods to call it after popping their events.
src/provider.rs (1)

130-130: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Collapse the repeated provider gate into one named feature.

The predicate any(feature = "openai", feature = "anthropic", feature = "gemini") now appears at lines 58, 62, 64, 130, 198, 213, 326, and 333. Each new provider requires editing every occurrence, and a missed site produces a feature-combination build break rather than a visible error.

Add an internal aggregate feature in Cargo.toml, for example _http_provider = [], have openai, anthropic, and gemini enable it, then gate on #[cfg(feature = "_http_provider")] at each site.

Also applies to: 198-198, 213-213, 326-333

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/provider.rs` at line 130, Replace the repeated provider cfg predicate in
src/provider.rs, including the sites around provider definitions and
HTTP-provider code, with #[cfg(feature = "_http_provider")]. Define the internal
_http_provider aggregate feature in Cargo.toml and update the openai, anthropic,
and gemini features to enable it, preserving their existing feature behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Cargo.toml`:
- Around line 99-104: Remove panic = "abort" from the [profile.release]
configuration so dispatch_tool’s catch_unwind-based tool-panic isolation remains
effective in release builds. Preserve the other release profile settings
unchanged.

In `@examples/chat.rs`:
- Around line 336-353: Update the runtime mode setup around `no_stream` so it is
true whenever the `streaming` feature is unavailable, ensuring the later
result-printing logic displays non-streaming responses. In the feature-enabled
live-streaming branch, explicitly select `TurnMode::Streaming` before
configuring the text streamer, while preserving the existing `NO_STREAM=1`
non-streaming behavior.

In `@README.md`:
- Around line 170-175: Update the README paragraphs describing streaming so they
distinguish feature availability from runtime mode selection: state that the
streaming feature enables TurnMode::Streaming, but turns use it only when
selected, including via set_turn_mode, while TurnMode::NonStreaming remains
available. Apply the same clarification to the referenced paragraph.

In `@src/engine/bare.rs`:
- Around line 122-134: Resolve the conflicting defaults for TurnMode by removing
its derived Default implementation and relying solely on default_turn_mode() for
the feature-dependent constructor default. Update the associated public
documentation to describe this single default contract accurately, while
preserving the enum variants and mode-switching behavior.
- Around line 136-144: Update the documentation for the cfg-gated Streaming
variant to remove the claim that disabling the streaming feature produces a
LoopError::Config at turn time, while retaining only the accurate streaming
feature requirement.

---

Nitpick comments:
In `@src/engine/bare.rs`:
- Around line 2708-2716: Rename the test function
turn_mode_default_is_nonstreaming_without_feature to reflect that it verifies
the default turn mode for both streaming and non-streaming feature
configurations. Keep the assertions and test behavior unchanged.
- Around line 2469-2494: Extract the duplicated event-to-response logic from
MockClient::create_message and RecordingClient::create_message into a shared
test helper such as assemble_response. The helper should accept queued
StreamEvent values, track the latest MessageDelta stop reason, process events
through StreamAccumulator, and return the constructed NonStreamingResponse or
ApiError; update both client methods to call it after popping their events.

In `@src/provider.rs`:
- Line 130: Replace the repeated provider cfg predicate in src/provider.rs,
including the sites around provider definitions and HTTP-provider code, with
#[cfg(feature = "_http_provider")]. Define the internal _http_provider aggregate
feature in Cargo.toml and update the openai, anthropic, and gemini features to
enable it, preserving their existing feature behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a114cd1-01ed-41f8-943b-b6b87b293fa5

📥 Commits

Reviewing files that changed from the base of the PR and between a7c0ef6 and 212f0dc.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • examples/chat.rs
  • src/capabilities.rs
  • src/engine/bare.rs
  • src/engine/bare/compact.rs
  • src/engine/bare/dispatch.rs
  • src/engine/bare/emission.rs
  • src/engine/bare/stream.rs
  • src/managers.rs
  • src/observer.rs
  • src/provider.rs
  • src/reflection/llm.rs
  • src/stream.rs
  • src/stream/rate_limit.rs
  • src/structured.rs

Comment thread Cargo.toml
Comment thread examples/chat.rs Outdated
Comment thread README.md Outdated
Comment thread src/engine/bare.rs Outdated
Comment thread src/engine/bare.rs
@bobrykov
bobrykov merged commit e6a04a6 into master Aug 2, 2026
7 checks passed
This was referenced Aug 3, 2026
@bobrykov
bobrykov deleted the feat/non-streaming-path branch August 4, 2026 05:23
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