Skip to content

refactor: narrow Any-typed fields to concrete types across core models#4762

Open
greysonlalonde wants to merge 13 commits intomainfrom
gl/refactor/narrow-any-types
Open

refactor: narrow Any-typed fields to concrete types across core models#4762
greysonlalonde wants to merge 13 commits intomainfrom
gl/refactor/narrow-any-types

Conversation

@greysonlalonde
Copy link
Contributor

@greysonlalonde greysonlalonde commented Mar 7, 2026

Note

Medium Risk
Changes Pydantic schemas/serialization for Crew/Task callbacks (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 across Crew and Flow (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 updates Task.callback, Crew.step_callback, and Crew.task_callback to use it; introduces optional crewai[pickling] extra (cloudpickle) with opt-in deserialization guard.

Flow behavior is slightly adjusted around memory remember() handling for list inputs and ask() timeout handling, and tests are updated to patch LLM in the correct module and to use VCR cassettes for _collapse_to_outcome coverage.

Written by Cursor Bugbot for commit e869cdc. This will update automatically on new commits. Configure here.

Base automatically changed from gl/refactor/memory-basemodel to main March 9, 2026 03:08


@overload
def build_embedder(spec: EmbedderConfig) -> EmbeddingFunction[Any]: ...
Copy link

@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.

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)
Copy link

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant