crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[FEATURE] Add exact historical Flow state lookup scoped to its UUID

Open lorenzejay opened this issue 1 month ago • 3 comments

Python PR scope

Add a read-only method to retrieve one historical state row by its stable row ID and Flow UUID, alongside the history listing API.

Difficulty: easy. 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

  • [ ] A row belonging to another Flow UUID must not be returned.
  • [ ] Return None for a missing record, and preserve the stored JSON state for a matching record.
  • [ ] Test nested state data, missing IDs, multiple flows, and latest-state API regression.
  • [ ] Use existing JSON decoding conventions and bound SQL parameters.
  • [ ] Do not change the active Flow state or add a historical resume API.

Dependencies and coordination

  • Depends on #8138.

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

I would like to take up this as a part of the Stanford collaboration.

sallyw02 avatar Oct 14 '26 18:10 sallyw02

@lorenzejay A quick question about the dependency on #8138: it's still unassigned with no PR, so the history listing API doesn't exist on main yet. Should I implement the lookup independently now, or wait for #8138? And should the lookup return the plain state dict like load_state, or the same typed history record that #8138 will introduce?

sallyw02 avatar Oct 15 '26 19:10 sallyw02

@lorenzejay Since #8253 now covers #8138, here is how I plan to tackle this one. Its history record carries only metadata, so this lookup fills in the state for a listed row.

  • Add SQLiteFlowPersistence.load_state_from_history(flow_uuid, record_id), returning dict[str, Any] | None like load_state.
  • Match on both the row id and the flow UUID with bound parameters, so a row from another flow is never returned. Missing rows and non-dict JSON return None, as in load_state.
  • Build it on main independently of #8253 and rebase if that merges first.
  • Keep it SQLite-only, with no base-class hook and no read-only module-level variant for #8140. Those can follow once #8253 settles.
  • Tests in test_flow_persistence.py for nested state, missing ids, multiple flows and load_state regression. No docs changes.

I plan to draft PR along these lines, but please let me know if you'd prefer otherwise.

sallyw02 avatar Oct 19 '26 06:10 sallyw02