8000 feat: Persist events on run response by dirkbrnd · Pull Request #3548 · agno-agi/agno · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 30 commits into from
Jun 17, 2025
Merged

Conversation

dirkbrnd
Copy link
Contributor

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

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Additional Notes

Add any important context (deployment instructions, screenshots, security considerations, etc.)

@dirkbrnd dirkbrnd requested a review from a team as a code owner June 12, 2025 12:10
@dirkbrnd dirkbrnd changed the base branch from main to fix/run-response-agent-name June 12, 2025 13:52
Base automatically changed from fix/run-response-agent-name to main June 13, 2025 12:52
)

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:
Copy link
Contributor

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

Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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

@dirkbrnd dirkbrnd merged commit de4f484 into main Jun 17, 2025
3 checks passed
@dirkbrnd dirkbrnd deleted the feat/add-events-on-runresponse branch June 17, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0