Repository navigation
CrewAI memory callbacks retain session protection - #893
Merged
Merged
Conversation
Automatic memory callbacks must retain their originating protection roots when the bound client changes. Native explicit tools keep their own ownership semantics. Add diagnostic cases before changing the adapter. Signed-off-by: zlareb1 <[email protected]>
A client rebind must not remove a conversation's constructor or earlier callback contributors. Join automatic protection at SDK dispatch only inside an application-owned automatic scope, and observe explicit tools. Signed-off-by: zlareb1 <[email protected]>
zlareb1
marked this pull request as ready for review
November 18, 2026 17:49
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
CrewAI memory callbacks retain their conversation's protection contributors across client rebinding. Protected automatic recall and capture refuse before HTTP, while explicit native memory tools remain explicit.
Why
LoomCrewMemoryloses constructor and earlier callback contributors when its client binding changes. Automatic callbacks can then dispatch after an originating contributor becomes protected. A marked recall must also reach retained contributors before the native memory callback returns content.The adapter uses the shared callback protection helper to retain constructor and callback contributors, including the pure
extract_memoriesproducer. Each SDK dispatch joins automatic protection only when the application already owns an automatic scope; otherwise it observes response protection. The SDK retains those contributors across authentication awaits and observes marked responses before native matches return.Scope and risk
Use one memory instance per conversation. Native user identifiers and the unsupported
privateflag do not select session protection. ExplicitRememberToolandRecallMemoryToolcalls outside an automatic scope keep their ownership. Query bodies, filtering, read-only behavior, and extraction contents retain their existing semantics.The tests use native
Crew.kickoff()and memory tools with the real SDK and an HTTPX mock transport. The existing scripted language model supplies the crew answer without a provider call. The fixture excludes inherited proxies before SDK construction through SDK close, and a separate assertion checks transport selection before any request.Compatibility, rollout and rollback
Tests
The test-only baseline produced the same 12 causal failures and 25 passes on both supported native CI legs: CrewAI 1.15.42 with Python 3.12 in 8.97 seconds, and CrewAI 1.15.0 with Python 3.11 in 5.67 seconds. The failures cover lost constructor and callback contributors, rebinding during authentication, marked recall, failed observation, and the real crew path dispatching two unwanted requests. Setup, imports, proxy isolation, and explicit-tool controls passed.
The fix preserves the entire 37-case test module byte-for-byte. Scoped Ruff format and lint checks, prose checks, and
git diff --checkpass. Local runtime checks remain blocked by the disk admission floor; no compatible task environment is available for a scoped type check. The corrected head passes all 37 cases on both supported native CI legs: CrewAI 1.15.42/Python 3.12 in 10.69 seconds and CrewAI 1.15.0/Python 3.11 in 4.33 seconds. Strict mypy passes four source files in both jobs. All 45 required checks are terminal: 43 pass and the two documentation publication checks are skipped. All four applicable workflows pass. Reproduce native checks withmake test-sdk-adapter-crewaion both supported dependency resolutions.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: An agent wrote the change. Independent source review, both native dependency resolutions and all required CI checks pass.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
git commit -s).