refactor: narrow Any-typed fields to concrete types across core models#4762
refactor: narrow Any-typed fields to concrete types across core models#4762greysonlalonde wants to merge 13 commits intomainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| def __exit__(self, *_: object) -> None: | ||
| token = _ALLOW_PICKLE_TOKEN.get() | ||
| if token is not None: | ||
| _ALLOW_PICKLE.reset(token) |
There was a problem hiding this comment.
Context manager fails on nested reentrant usage
Medium Severity
_AllowPickleDeserialization is documented as "reentrant" but isn't. On __enter__, it stores the _ALLOW_PICKLE reset token into _ALLOW_PICKLE_TOKEN but discards the token returned by _ALLOW_PICKLE_TOKEN.set(...). When nested, the inner __exit__ consumes the token, then the outer __exit__ reads the same (already-used) token from _ALLOW_PICKLE_TOKEN and calls _ALLOW_PICKLE.reset(token), raising a ValueError because the token was already consumed.
|
This PR is stale because it has been open for 45 days with no activity. |


Note
Medium Risk
Changes Pydantic schemas/serialization for
Crew/Taskcallbacks (now cloudpickle-based) and tightens core model types, which could affect compatibility and introduces opt-in pickle deserialization considerations.Overview
Narrows previously
Any-typed fields acrossCrewandFlow(LLM fields, memory types, tracing span, input provider) to concrete unions, and refactors related helpers/imports accordingly.Adds callback serialization support via new
SerializableCallable(cloudpickle+base64) and updatesTask.callback,Crew.step_callback, andCrew.task_callbackto use it; introduces optionalcrewai[pickling]extra (cloudpickle) with opt-in deserialization guard.Flow behavior is slightly adjusted around memory
remember()handling for list inputs andask()timeout handling, and tests are updated to patchLLMin the correct module and to use VCR cassettes for_collapse_to_outcomecoverage.Written by Cursor Bugbot for commit e869cdc. This will update automatically on new commits. Configure here.