Fix agent printing too often while thinking#1172
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR reduces the frequency of agent prints during thinking by coarsening the timestamp resolution used in the stable event ID.
- Changed timestamp granularity from full ISO format to hour-level only
- Affects how event IDs are generated to prevent repeated prints within the same hour
Comments suppressed due to low confidence (2)
src/marvin/handlers/print_handler.py:233
- Add a comment explaining why the timestamp is truncated to the hour (e.g., to batch prints within the same hour), so future readers understand the rationale.
msg_time = event.timestamp.isoformat(timespec='hour')
src/marvin/handlers/print_handler.py:233
- Add a unit test to verify that events within the same hour produce the same
event_idand that events in different hours produce distinct IDs.
msg_time = event.timestamp.isoformat(timespec='hour')
|
actually @wreed4 can you share what model / setup you have here? |
|
I'm using just the regular sonnet models. They're coming through a litellm, but as far as I can tell that's not the issue. the issue only was that that code would make a new panel every time that "stable id" changes. And the stable id was "actor name" + "timestamp". but the time would be different on the millisecond, so the code would just.. essentially always make new panels for every event. because every token of "thought" back from the model is more than a millisecond away from the last one. maybe it's streaming them now and in the past it didn't so the whole thought would come back at once and this bug wasn't visible? 🤷 |
|
@zzstoatzz did this get handled in a different change? |
|
i don't really understand why this change is necessary as i haven't reproduced but i should have explained that when closing. im fine with merging it and testing it out in main for a bit before releasing |
This change fixes the logic in the print handler allowing thinking events to print within the same panel. Without this logic, Marvin would make a new panel if thinking events were even a millisecond apart, which happens quite frequently 😉.