-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: Persist events on run response #3548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-events-on-runresponse
…response-agent-name
…-agi/agno into feat/add-events-on-runresponse
…-agi/agno into fix/run-response-agent-name
…-agi/agno into feat/add-events-on-runresponse
…-events-on-runresponse
…-events-on-runresponse
libs/agno/agno/agent/agent.py
Outdated
) | ||
|
||
def _handle_event(self, event: RunResponseEvent, run_response: RunResponse): | ||
# We only store events that are not run_response_content events | ||
if self.store_events and event.event != RunEvent.run_response_content.value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in future there could be more events that we'd want to skip? Maybe we can make a list of which events are persisted and it'll be easier to document them as well that way. Not a big one, but just mentioning.
PERSISTED_EVENTS = {
RunEvent.run_started.value,
RunEvent.run_completed.value,
RunEvent.tool_call_started.value,
RunEvent.tool_call_completed.value,
# ...add others
}
def _handle_event(self, event: RunResponseEvent, run_response: RunResponse):
if self.store_events and event.event in PERSISTED_EVENTS:
if run_response.events is None:
run_response.events = []
run_response.events.append(event)
return event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is a good idea. I'll make it configurable
self.save_run_response_to_file(message=message, session_id=session_id) | ||
|
||
if stream_intermediate_steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This event should remain as the last function executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be stored on the session if I don't make this change
Summary
Give users the option to persist all the events on the final run response so they can see everything that happened.
We explicitly don't do that with content, as that will bloat it too much.
Type of change
Checklist
./scripts/format.sh
and./scripts/validate.sh
)Additional Notes
Add any important context (deployment instructions, screenshots, security considerations, etc.)