Add Support for Simulated Streaming Toggle and Provider Compatibility Checks
Summary:
This PR introduces configuration options and logic to handle simulated streaming, allowing flexibility when native streaming support is unavailable from certain providers. It adds an environment-aware support check for multiple providers to prevent misconfiguration, ensuring the application only proceeds with simulated streaming when appropriate.
| Provider | Native Streaming Support | Behavior with --enable-simulated-streaming=true (default) |
Behavior with --enable-simulated-streaming=false |
|---|---|---|---|
| openai | No | Works with simulated streaming | Fails at startup with error message |
| grok | No | Works with simulated streaming | Fails at startup with error message |
| gemini | Yes | Works with native streaming | Works with native streaming |
| ollama | No | Works with native streaming | Fails at startup with error message |
| llamacpp | No | Works with native streaming | Fails at startup with error message |
| azopenai | No | Works with native streaming | Fails at startup with error message |
| unknown | Assumed No | Works with simulated streaming | Fails at startup with error message |
When the application starts:
- If
--enable-simulated-streaming=false, the code checks if the selected provider supports native streaming - If native streaming is not supported, it fails immediately with an error message
- If native streaming is supported, it sets environment variables (
KUBECTL_AI_REQUIRE_NATIVE_STREAMING=trueand provider-specific variables) and continues
This approach ensures that applications that depend on real-time token-by-token streaming for UI updates or early termination can enforce this requirement at startup time.
Affected Modules:
- cmd/main.go (Options definition, CLI flag binding, environment setup)
- main logic flow (runtime streaming capability validation)
- provider support detection (checkNativeStreamingSupport function)
Key Details:
- Adds a new CLI flag
--enable-simulated-streamingwith a default value oftrue. - Implements
checkNativeStreamingSupport()to determine if a provider natively supports streaming features, with default assumptions. - During runtime, if
--enable-simulated-streaming=falseis specified, the code verifies provider support before proceeding. - Ensures users are warned about provider limitations and configuration mismatches, preventing runtime errors.
Potential Impacts:
- Users can explicitly disable simulated streaming, but only if their provider supports native streaming.
- Prevents misconfiguration by aborting excessive unsupported setup attempts.
- Enhances robustness across multiple providers with varying streaming capabilities.
- Adds flexibility for future providers by expanding support checks in
checkNativeStreamingSupport().
Testing Steps:
- Run with
--enable-simulated-streaming=falseagainst providers known to support native streaming (gemini), verify normal operation. - Run with
--enable-simulated-streaming=falseagainst providers without native streaming support (azopenai,grok,llamacpp,ollama,openai) and confirm proper error handling. - Verify default behavior with
--enable-simulated-streamingomitted, ensuring it defaults to allowing simulated streaming. - Confirm CLI flag parsing correctly sets the configuration and influences runtime validation.
- Test warning logs for unknown providers to ensure future compatibility.
Just realized this was open, perhaps #215 solves what is mentioned here
Just realized this was open, perhaps #215 solves what is mentioned here
I think so too. Awesome to see the progress on the streaming (and auto-detection/fallback).