Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit 0a10b70

Browse files
authored
fix: update agent event logger (#10)
Fixes this: <img width="1035" alt="image" src="https://github.com/user-attachments/assets/2e43d8c9-2f76-40fb-ab21-abec2f161f95" />
1 parent d79345e commit 0a10b70

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/llama_stack_client/lib/agents/event_logger.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This source code is licensed under the terms described in the LICENSE file in
55
# the root directory of this source tree.
66

7-
from typing import Any, Iterator, Optional, Tuple
7+
from typing import Any, Iterator, Optional
88

99
from termcolor import cprint
1010

@@ -55,17 +55,10 @@ def print(self, flush: bool = True) -> None:
5555

5656

5757
class TurnStreamEventPrinter:
58-
def __init__(self) -> None:
59-
self.previous_event_type: Optional[str] = None
60-
self.previous_step_type: Optional[str] = None
61-
6258
def yield_printable_events(self, chunk: Any) -> Iterator[TurnStreamPrintableEvent]:
63-
for printable_event in self._yield_printable_events(chunk, self.previous_event_type, self.previous_step_type):
59+
for printable_event in self._yield_printable_events(chunk):
6460
yield printable_event
6561

66-
if not hasattr(chunk, "error"):
67-
self.previous_event_type, self.previous_step_type = self._get_event_type_step_type(chunk)
68-
6962
def _yield_printable_events(self, chunk: Any) -> Iterator[TurnStreamPrintableEvent]:
7063
if hasattr(chunk, "error"):
7164
yield TurnStreamPrintableEvent(role=None, content=chunk.error["message"], color="red")
@@ -144,17 +137,6 @@ def _yield_printable_events(self, chunk: Any) -> Iterator[TurnStreamPrintableEve
144137
color="green",
145138
)
146139

147-
def _get_event_type_step_type(self, chunk: Any) -> Tuple[Optional[str], Optional[str]]:
148-
if hasattr(chunk, "event"):
149-
previous_event_type = chunk.event.payload.event_type if hasattr(chunk, "event") else None
150-
previous_step_type = (
151-
chunk.event.payload.step_type
152-
if previous_event_type not in {"turn_start", "turn_complete", "turn_awaiting_input"}
153-
else None
154-
)
155-
return previous_event_type, previous_step_type
156-
return None, None
157-
158140

159141
class EventLogger:
160142
def log(self, event_generator: Iterator[Any]) -> Iterator[TurnStreamPrintableEvent]:

0 commit comments

Comments
 (0)