@@ -22,6 +22,7 @@ use protocol::{
2222 LoopError ,
2323 SendRequestArgs ,
2424 StreamMetadata ,
25+ StreamResult ,
2526 UserTurnMetadata ,
2627} ;
2728use serde:: {
@@ -124,10 +125,7 @@ pub struct AgentLoop {
124125
125126 /// The current response stream future being received along with it's associated parse state
126127 #[ allow( clippy:: type_complexity) ]
127- curr_stream : Option < (
128- StreamParseState ,
129- Pin < Box < dyn Stream < Item = Result < StreamEvent , StreamError > > + Send > > ,
130- ) > ,
128+ curr_stream : Option < ( StreamParseState , Pin < Box < dyn Stream < Item = StreamResult > + Send > > ) > ,
131129
132130 /// List of completed stream parse states
133131 stream_states : Vec < StreamParseState > ,
@@ -434,7 +432,9 @@ impl StreamParseState {
434432 }
435433 }
436434
437- pub fn next ( & mut self , ev : Option < Result < StreamEvent , StreamError > > , buf : & mut Vec < AgentLoopEventKind > ) {
435+ // pub fn next(&mut self, ev: Option<Result<StreamEvent, StreamError>>, buf: &mut
436+ // Vec<AgentLoopEventKind>) {
437+ pub fn next ( & mut self , ev : Option < StreamResult > , buf : & mut Vec < AgentLoopEventKind > ) {
438438 if self . errored {
439439 if let Some ( ev) = ev {
440440 warn ! ( ?ev, "ignoring unexpected event after having received an error" ) ;
@@ -457,13 +457,10 @@ impl StreamParseState {
457457
458458 // Pushing low-level stream events in case end users want to consume these directly. Likely
459459 // not required.
460- match & ev {
461- Ok ( e) => buf. push ( AgentLoopEventKind :: StreamEvent ( e. clone ( ) ) ) ,
462- Err ( e) => buf. push ( AgentLoopEventKind :: StreamError ( e. clone ( ) ) ) ,
463- }
460+ buf. push ( AgentLoopEventKind :: Stream ( ev. clone ( ) ) ) ;
464461
465462 match ev {
466- Ok ( s) => match s {
463+ StreamResult :: Ok ( s) => match s {
467464 StreamEvent :: MessageStart ( ev) => {
468465 debug_assert ! ( ev. role == Role :: Assistant ) ;
469466 } ,
@@ -543,7 +540,7 @@ impl StreamParseState {
543540
544541 // Parse invariant - we don't expect any further events after receiving a single
545542 // error.
546- Err ( err) => {
543+ StreamResult :: Err ( err) => {
547544 debug_assert ! (
548545 self . stream_err. is_none( ) ,
549546 "Only one stream error event is expected. Previously found: {:?}, just received: {:?}" ,
0 commit comments