crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[FEATURE] Add read-only CLI listing and inspection for persisted Flow states

Open lorenzejay opened this issue 1 month ago • 3 comments

Python PR scope

Expose the new flow_states history/read API through the existing CLI organization, with text and machine-readable JSON output. Make the storage kind explicit so this is not confused with full-object checkpoints.

Difficulty: medium. Allocation index: #8118. Project: #8121.

Cohort allocation

This ticket is reserved for maintainer-coordinated allocation to the Stanford semester collaboration. Please wait for @lorenzejay to confirm an assignee before implementing. A comment expresses interest; it does not establish ownership. Public good first issue / help wanted discovery labels will be considered after cohort allocation.

GitHub usernames have not yet been supplied, so no individual assignment is implied.

Acceptance criteria

  • [ ] Support a user-specified database path, Flow UUID, bounded history listing, and exact record inspection.
  • [ ] Reuse Click/Rich conventions and confirm the command shape with maintainers before implementation.
  • [ ] Never create a missing database, write state, or change journal settings as a side effect of inspection.
  • [ ] Test JSON output, empty/missing stores, wrong UUIDs, invalid limits, and unsupported SQLite schemas with CliRunner/temp files.
  • [ ] Keep existing checkpoint list/info/resume commands unchanged.

Dependencies and coordination

  • Depends on #8138.
  • Depends on #8139.

Starting points

Submission

The contributor implements this scope and submits one focused PR linked to this open issue. Include full Python annotations, behavioral tests, and relevant quality checks. No paid API calls are required for the tests. Preserve existing APIs outside the scoped feature. For newly found defects, reproduce them and check active issues/PRs before fixing them. Docs edits, when needed, belong under docs/edge/ and must sync ar, ko, pt-BR per DOCS_TRANSLATIONS.md. Follow .github/CONTRIBUTING.md. Issue prepared with AI assistance.

lorenzejay avatar Oct 13 '26 22:10 lorenzejay

Hi @lorenzejay,

I would like to take this issue.

Plan:

  1. Implement a clean read-only inspection query on SQLiteFlowPersistence that fetches historical state metadata without triggering schema/journal initialization side-effects.
  2. Expose the CLI subcommand (crewai flow list-states / inspect-state) to display formatted tables of execution timestamps, step methods, and state metadata.
  3. Add unit tests covering multiple UUIDs, pagination, and invalid Flow IDs.

Could you please assign this to me

Rohitkanithi avatar Oct 17 '26 01:10 Rohitkanithi

Hi @lorenzejay, I'm in the Stanford cohort (I did #8129 / #8167) and would like to take this one.

Proposed command shape, under the existing crewai flow group:

  • crewai flow states <FLOW_UUID> --db PATH [--limit N] [--offset N] [--json]: a bounded history listing built on list_state_history from #8253.
  • crewai flow state <FLOW_UUID> <RECORD_ID> --db PATH [--json]: exact record inspection via load_state_from_history from #8272.

The output would label the storage kind as flow_states so it isn't confused with checkpoints. Inspection opens SQLite read-only (mode=ro URI), so it never creates a missing database, writes state, or changes journal settings. Tests would use CliRunner with temp files and cover JSON output, empty and missing stores, wrong UUIDs, invalid limits, and unsupported schemas. crewai checkpoint commands stay unchanged.

I'll build against #8253's interface and rebase once it merges. Does this command shape work for you?

namupta-max avatar Nov 13 '26 18:11 namupta-max

Hi @lorenzejay — I'd like to take this ticket if it's still unallocated. I'm a student in the Stanford CS 146S cohort.

Plan

  1. Confirm the command shape with you before writing code (e.g. list and info subcommands for flow states, kept separate from the existing checkpoint commands so the storage kind is explicit).
  2. Build exact-record inspection first, on top of SQLiteFlowPersistence.load_state_from_history, which is already on main.
  3. Add bounded history listing once #8138 lands, reusing its API rather than writing a second query path.
  4. Open the database read-only, so inspection never creates a missing file, writes state, or changes journal settings.
  5. Provide Rich text output and --json output, following the conventions in checkpoint_cli.py.
  6. Add CliRunner tests with temp files for JSON output, empty and missing stores, wrong UUIDs, invalid limits, and unsupported schemas.

Outcome One focused PR linked to this issue, with full type annotations and tests that need no paid API calls. Existing checkpoint list/info/resume behaviour stays unchanged.

Question Since listing depends on #8138, would you prefer I wait for it, or submit inspection first and listing as a follow-up?

I won't start implementing until you confirm the assignment.

keyiyu0331 avatar Nov 13 '26 23:11 keyiyu0331