Skip to content

[Bug] DB upsert failures are not raised in Agno 2.0 #4755

@undera

Description

@undera

Description

While migrating from Agno 1.x onto 2.x I have noticed that any issue happening inside session upsert (also session read) is being silenced. As a result, very critical act of saving the progress can be missed by application. This gives no chance for detection of the problem, reporting it or retrying it.
IMO this is wrong design for library, to hide the fact of such a critical failure.
The problem is coming from this place in code: https://github.com/agno-agi/agno/blob/main/libs/agno/agno/agent/agent.py#L4253

Steps to Reproduce

Have a storage for Agent that would fail to save, for example into Postgres due to temporary problem of connection. Just run the agent with that situation. This is also possible to simulate on unit test level.

Agent Configuration (if applicable)

N/A

Expected Behavior

I would expect for any hard error from persistence DB layer to be raised, so the application knows when things aren't functioning normally.

Actual Behavior

I only see warnings in logs like WARNING root:log.py:212 Error upserting session into db: 'Metrics' object is not subscriptable, and lucky I am that I looked at the log before deploying this code into prod. I don't even have a stacktrace to understand where the problem has happened.

Screenshots or Logs (if applicable)

No response

Environment

- OS: Linux
- Agno: 2.0.8

Possible Solutions (optional)

IMO the default behavior should be to raise the exception, as it is very critical error. Introducing a field into agent "raise_db_errors" is also possible, but I'd have it False as default.

What I think would be the best design is to leave the decision of raising or swallowing the exception to the DB instance itself. Then it's easy to subclass DB and add exception handling there.

Additional Context

Looks like reading from storage has the same problem. As a result the temporary problem of reading the session could cause the broken behavior of starting new session where old one should have been continued.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions