Skip to content

fix: log persistence storage location for @persist decorator#5373

Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/1775705728-persist-storage-path-visibility
Open

fix: log persistence storage location for @persist decorator#5373
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/1775705728-persist-storage-path-visibility

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Apr 9, 2026

Summary

When using @persist on a flow, users had no way to discover where their flow state was being stored. The default SQLiteFlowPersistence resolves its path via appdirs.user_data_dir(), which is platform-specific and was never surfaced to the user. This addresses #5372.

Changes:

  • SQLiteFlowPersistence._setup() now logs the resolved db_path at INFO level on initialization
  • PersistenceDecorator.persist_state() now logs the storage location (the db_path for SQLite, or the class name for custom backends) at INFO level after each state save
  • When verbose=True, the storage location is also printed to the console via PRINTER
  • Adds 5 new tests covering path discoverability (init logging, save logging, verbose output, class-level decorator)

Behavioral note: The old save_state log message was renamed from "Saving flow state to memory for ID: {}" to "Saving flow state for ID: {}". The storage location is now logged unconditionally at INFO level on every save (previously, no log was emitted with verbose=False).

Review & Testing Checklist for Human

  • Verify the INFO-level log on every save is acceptable noise. The storage location is logged at INFO on every persist_state() call, not just the first. For flows with many persisted steps, this could be chatty. Consider whether this should be DEBUG instead, or only logged once per persistence instance.
  • Check the removed QuietFlow test was intentional. The old test asserted that verbose=False produced no "Saving flow state" logs. This assertion is no longer valid because storage location is now always logged at INFO. The test was removed rather than updated — confirm this behavioral change is desired.
  • Verify getattr fallback for custom persistence backends. For non-SQLite backends without a db_path attribute, the log falls back to type(persistence_instance).__name__. Confirm this is useful enough for custom implementations.

Notes

  • To manually verify: run any flow with @persist() and check that the log output includes the SQLite database path. Enable Python INFO logging (e.g., logging.basicConfig(level=logging.INFO)) or use verbose=True on the decorator.

Link to Devin session: https://app.devin.ai/sessions/0bf4c592e402444eb5656a8159404869


Note

Low Risk
Low risk behavior change limited to additional INFO-level logging during persistence initialization and every state save; main concern is potential log noise or tests that assume quiet default logging.

Overview
Makes persisted flow state discoverable by logging where it is stored.

@persist now logs an INFO message after each save that includes the flow ID and the persistence storage location (uses db_path when available, otherwise the backend class name), and prints the same message to the console when verbose=True. SQLiteFlowPersistence also logs its resolved db_path on initialization.

Updates and expands tests to cover the new logging behavior (including default path logging, save-time storage logging, verbose output, and class-level @persist).

Reviewed by Cursor Bugbot for commit 3758361. Bugbot is set up for automated code reviews on this repo. Configure here.

When using @persist, users had no way to discover where their flow state
was being stored. The default SQLiteFlowPersistence uses appdirs which
varies by platform, making the database location opaque.

Changes:
- Log db_path at INFO level when SQLiteFlowPersistence is initialized
- Log storage location (db_path) after each state save in persist decorator
- Show storage location in console output when verbose=True
- Add 5 new tests covering persistence path discoverability

Closes #5372

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Prompt hidden (unlisted session)

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added the size/M label Apr 9, 2026
Co-Authored-By: João <joao@crewai.com>
Comment thread lib/crewai/tests/test_flow_persistence.py Fixed
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e22d185. Configure here.

Comment thread lib/crewai/src/crewai/flow/persistence/decorators.py
…og messages

Co-Authored-By: João <joao@crewai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants