Skip to content

Feat/prefer streaming#44

Open
harshpreet931 wants to merge 4 commits into
mainfrom
feat/preferStreaming
Open

Feat/prefer streaming#44
harshpreet931 wants to merge 4 commits into
mainfrom
feat/preferStreaming

Conversation

@harshpreet931
Copy link
Copy Markdown
Collaborator

This pull request introduces a new preferStreaming configuration option to the agent and model execution pipeline, allowing callers to control whether streaming responses are preferred when available. The changes propagate this option through multiple layers of the codebase, update type definitions, and ensure that model providers respect the streaming preference. The most important changes are grouped below:

Streaming Preference Propagation

  • Added a preferStreaming property to the RunConfig type in src/core/types.ts, enabling configuration of streaming preference for model responses.
  • Passed the preferStreaming option through agent and guardrail invocations, ensuring it is available in downstream config objects (src/core/agent-as-tool.ts, src/core/guardrails.ts). [1] [2]

Model Execution Logic

  • Updated the logic in runInternal in src/core/engine.ts to check preferStreaming before using the streaming completion API, providing more granular control over streaming behavior. [1] [2]

Model Provider Implementation

  • Modified the LiteLLM provider in src/providers/model.ts to always set stream: false for non-streaming completions, ensuring explicit control over request streaming based on configuration.

Introduce a new optional `preferStreaming` boolean in `RunConfig` to allow users to explicitly enable or disable streaming for model completions. When set to `false`, streaming is skipped even if the provider supports it. This provides better control over response handling, especially in scenarios where non-streaming is preferred for simplicity or compatibility.

- Added `preferStreaming` to `RunConfig` type.
- Propagated the option in `agentAsTool`, `guardrails`, and engine logic.
- Updated model provider to explicitly set `stream: false` for non-streaming calls.
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