Repository navigation
feat: support rcrewai 0.8 (checkpointing, interceptors, event hierarchy) - #26
Merged
Merged
Conversation
rcrewai 0.8.0 is backward compatible for this engine: the 0.7.1 suite
passed against it unchanged before any code was touched. So this is
feature adoption rather than repair, following the established pattern of
nullable columns that emit a key only when meaningfully set.
Checkpointing. ActiveRecordCheckpointStore persists crew checkpoints to
the new rcrewai_checkpoints table, implementing the gem's store contract
(save/load/list/delete) the way ActiveRecordStateStore already does for
Flow. Records are stored verbatim as JSON so a record written by any
store implementation round-trips identically. crew.resume_sync/_async
replay tasks that already completed instead of paying for them again;
executions record run_id/parent_run_id so a resumed run links back to the
one it continues and Checkpoint.lineage walks the chain. Off by default,
with a per-crew checkpoint_enabled column.
Interceptors. config.llm_before_request/llm_after_response attach the new
hooks to every client the engine builds. The gem forwards hooks only
through LLMClient.for_provider, but agents resolve their client via
LLMClient.resolve, which does not - so hooks configured on the engine
would silently never fire on a per-agent LLM. Registering them on the
built client covers every path.
Providers. openai_compatible, bedrock, snowflake and openai_responses
needed no engine change (provider values pass through to the gem), but
they are now covered by specs and documented in the initializer.
Two bugs fixed along the way, both reproduced with a failing test first:
- Crew inputs never reached the gem. CrewExecutionJob persisted the
execution's inputs but called rcrew.execute without them, so
before_kickoff hooks and Crew#last_inputs always saw {} and no task
could interpolate an input. Pre-existing, unrelated to the upgrade.
- Concurrent runs of the same agent shared one span stack. The collector
keyed open spans by agent name, so one run's tool call could nest under
the other run's iteration, and its usage, text and errors could land on
the wrong span. 0.8 stamps every event with the id of its enclosing run
span - probing the real gem confirms this is a flat per-run id rather
than a nested tree, so it is for attribution, not nesting. The
collector now scopes its bookkeeping by it. Events without one (older
streams, and the engine's own crew/agent spans) keep the previous
behavior.
Verified the 012 migration against a simulated pre-0.8 schema, and that
the packaged gem actually contains the new files - they were untracked,
so git ls-files would have shipped them missing.
258 examples, 0 failures (was 221).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0123Ahvp1Cd6DoAgfr5bsYm2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracks rcrewai 0.8.0.
The upgrade did not break anything
Bumping the dependency and running the existing suite against 0.8.0 passed 221/221 unchanged. The release is genuinely additive for this engine, so this PR is feature adoption rather than repair.
Added
ActiveRecordCheckpointStorepersists crew checkpoints to the newrcrewai_checkpointstable, implementing the gem'ssave/load/list/deletecontract the wayActiveRecordStateStorealready does for Flow. Records are stored verbatim as JSON, so a record written by any store implementation round-trips identically.crew.resume_sync(execution)/resume_asyncreplay tasks that already completed instead of paying for them again. Executions recordrun_id/parent_run_id, so a resumed run links back to the one it continues andRCrewAI::Checkpoint.lineagewalks the chain. Off by default, with a per-crewcheckpoint_enabledcolumn.config.llm_before_request/llm_after_response. Worth noting: the gem forwards hooks only throughLLMClient.for_provider, but agents resolve their client viaLLMClient.resolve, which does not — so hooks configured on the engine would silently never fire on a per-agent LLM. Registering them on the built client covers every path.openai_compatible,bedrock,snowflake,openai_responsesneeded no engine change (provider values pass through), but are now spec-covered and documented in the generated initializer.Fixed
Both reproduced with a failing test first.
CrewExecutionJobpersisted the execution'sinputsbut calledrcrew.executewithout them, sobefore_kickoffhooks andCrew#last_inputsalways saw{}and no task could interpolate an input. Pre-existing, unrelated to the upgrade.Verification
012migration applied against a simulated pre-0.8 schema, which is the path existing installs actually take.git ls-filesin the gemspec would have shipped them missing.Upgrading
Adds
rcrewai_checkpoints,rcrewai_crews.checkpoint_enabled, andrun_id/parent_run_idon executions. Checkpointing is off by default, so nothing changes until enabled.Known issue, left alone
The suite is order-dependent:
--order randomfails ~87 examples on the original code too, becausereal_migrate_spec.rbswaps the global DB connection. It predates this work and deserves its own fix.🤖 Generated with Claude Code
https://claude.ai/code/session_0123Ahvp1Cd6DoAgfr5bsYm2