crewai - 💡(How to fix) Fix [FEATURE] Memory write guards for multi-agent crews — prevent cross-agent memory poisoning [1 pull requests]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

Why this matters for CrewAI specifically: Multi-agent crews amplify the risk because one poisoned memory entry propagates to ALL agents. A single injection in a researcher agent's output can compromise the writer and reviewer agents permanently.

Fix Action

Fixed

Code Example

from crewai import Crew, Agent, Task
from agent_memory_guard import scan_text

def memory_validator(content: str) -> bool:
    result = scan_text(content)
    return result.risk_level != "critical"

crew = Crew(
    agents=[researcher, writer, reviewer],
    tasks=[...],
    memory=True,
    memory_guard=memory_validator  # New parameter
)
RAW_BUFFERClick to expand / collapse

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

NA - not related to an existing bug

Describe the solution you'd like

In multi-agent CrewAI crews, agents share memory (short-term, long-term, entity memory). A compromised or manipulated agent can poison shared memory with prompt injection payloads that affect all other agents in the crew.

Proposed solution: Add a memory_guard parameter to Crew that validates all memory writes before persistence:

from crewai import Crew, Agent, Task
from agent_memory_guard import scan_text

def memory_validator(content: str) -> bool:
    result = scan_text(content)
    return result.risk_level != "critical"

crew = Crew(
    agents=[researcher, writer, reviewer],
    tasks=[...],
    memory=True,
    memory_guard=memory_validator  # New parameter
)

This would intercept writes to all memory types (short-term, long-term, entity) and block content that matches injection patterns. The agent-memory-guard package (OWASP project, 59µs latency, zero deps) provides a production-ready validator.

Why this matters for CrewAI specifically: Multi-agent crews amplify the risk because one poisoned memory entry propagates to ALL agents. A single injection in a researcher agent's output can compromise the writer and reviewer agents permanently.

Describe alternatives you've considered

  1. Per-agent input validation — doesn't catch tool outputs or inter-agent messages that flow into memory
  2. Post-hoc memory cleanup — reactive rather than preventive, damage already done by the time you detect it
  3. Disabling shared memory — defeats the purpose of multi-agent collaboration

Additional context

Willingness to Contribute

Yes, I'd be happy to submit a pull request

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING