pub struct HttpStreamingTool { /* private fields */ }Expand description
HTTP tool with first-class streaming surface (Fase 34.e).
stream() drives a reqwest::Client::post(url) async request +
drains response.bytes_stream() chunk-by-chunk. Content-Type
header decides framing:
text/event-stream→ SSE per W3C spec. Eachdata:field from a complete SSE event emits as aToolChunk::intermediate.event:/id:/retry:fields are dropped (the adopter sees only the data payload — the framing was for HTTP transport).application/x-ndjson/application/jsonl→ oneToolChunk::intermediateper LF-delimited line. Empty lines are skipped.- Other (
application/json,text/plain, raw bytes) → singleToolChunk::intermediatewith the full body accumulated, then a terminator. This is the D9 backwards-compat path for non-streaming HTTP endpoints — the same response shapedispatch_httpreturns synchronously, projected onto the single-chunk streaming surface.
§Cancel discipline (D5)
ctx.cancel is polled between every bytes_stream().next().await
boundary. When fired, the stream drops the reqwest::Response
(closing the connection) + emits a single
ToolFinishReason::Cancelled terminator chunk. Wall-clock budget
is bounded by the network roundtrip latency to the next chunk
arrival (typically ≤100ms for SSE streams with regular keepalive).
§Error discipline
Every failure surface (URL invalid / client build / connect /
timeout / non-2xx status / mid-stream byte error / I/O error)
is captured as a ToolFinishReason::Error { message } terminator
chunk — the consumer never sees a panic or a silently-truncated
stream.
Implementations§
Source§impl HttpStreamingTool
impl HttpStreamingTool
Trait Implementations§
Source§impl Tool for HttpStreamingTool
impl Tool for HttpStreamingTool
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
args: String,
_ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
args: String,
_ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
ToolResult. EVERY tool MUST implement this method
(no default — there’s no sensible default execute).Source§fn stream<'life0, 'async_trait>(
&'life0 self,
args: String,
ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = ToolStream> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stream<'life0, 'async_trait>(
&'life0 self,
args: String,
ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = ToolStream> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn is_streaming(&self) -> bool
fn is_streaming(&self) -> bool
false. Read moreAuto Trait Implementations§
impl Freeze for HttpStreamingTool
impl RefUnwindSafe for HttpStreamingTool
impl Send for HttpStreamingTool
impl Sync for HttpStreamingTool
impl Unpin for HttpStreamingTool
impl UnsafeUnpin for HttpStreamingTool
impl UnwindSafe for HttpStreamingTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more