Levr
All articles
Agentic Security

How to Prevent Context Poisoning in AI Coding Agents

Multi-agent systems let specialized coding agents draw on information, tools, and decisions held across a whole engineering team. The real risk isn't just exchanging messages. It's retrieving the smallest useful context without an untrusted source silently poisoning what an agent believes.

MMichael SwindellSeptember 2, 202617 min read

Multi-agent systems coordinate specialized software agents so that a request can draw on information, tools, and decisions held across a team. Their real engineering challenge is not simply getting agents to exchange messages. It is retrieving the smallest useful set of context at the point an agent must answer or act, while respecting privacy, security, and ownership boundaries. In practice, this requires carefully designed access scopes, privacy-preserving tools, shared knowledge spaces, approval paths, and auditability.

For engineering teams, an agent-first control plane such as Levr can connect task intent, verification, and work history so agents operate with project context rather than an isolated prompt. This kind of cross-agent safeguard fits within Levr's broader agentic control plane, see What Is Agentic Software Development?

At a Glance

Multi-agent coordination is primarily a context, privacy, and governance problem.

  • Core challenge: Agents need relevant context before making an answer, decision, or tool call.
  • Privacy constraint: The most useful information is often distributed across private inboxes, repositories, documents, and business systems.
  • Practical near-term pattern: Shared knowledge spaces maintained by policy-aware agents can reduce siloed information.
  • Main risk: Poorly governed shared memory can preserve incorrect facts, unsafe instructions, or sensitive information.
  • Operating principle: Automate low-sensitivity sharing first, while keeping high-impact disclosures reviewable and reversible.

Why are multi-agent systems really a context retrieval problem?

Multi-agent systems work well when the final agent has the right context at the moment it needs to reason or act. Agent-to-agent messages matter only insofar as they improve that context, reduce uncertainty, and support a correct tool call or response.

It is tempting to treat multi-agent architecture as a problem of delegation: one agent plans, another writes code, another runs tests, and another reports status. That model is incomplete. The harder question is whether each agent can find the information needed to do its assigned work without receiving irrelevant, stale, or unauthorized data.

For example, a coding agent asked to fix a production defect may need acceptance criteria, related incidents, recent pull requests, test results, and ownership information. Before agents can safely act within trust boundaries, they often need to resolve ambiguous requirements first — see how coding agents clarify ambiguous requirements. A second agent can retrieve some of that material, but the outcome only improves if the final working context is both accurate and appropriately scoped.

This reframing also explains why adding more agents does not automatically improve a system. More agents can create more tool calls, duplicated searches, inconsistent summaries, and fragmented memory. The goal is not maximum delegation. The goal is reliable access to the minimum context required for a useful action.

What is the ideal information model for an agent network?

The theoretical ideal is an agent that can access every relevant source and reason over it instantly. Real systems cannot operate that way because privacy, security, organizational ownership, and compliance create necessary limits on who or what may access information.

An unrestricted agent could combine project data, internal communication, customer history, system telemetry, and organizational knowledge to produce highly informed answers. In a real company, however, those sources have different owners and sensitivity levels. An engineer should not automatically gain access to HR records. A sales workflow should not expose confidential recruiting conversations.

The design target is therefore not universal access. It is a close approximation of universal relevance under explicit trust boundaries. A well-designed system should let an agent discover that useful information exists, obtain only permitted details, and ask for approval when disclosure carries material risk.

This resembles a transaction-cost problem. When information is expensive or risky to share, teams lose opportunities to coordinate. Agent systems can reduce the cost of finding and routing context, but they should not remove the controls that protect people and organizations.

Which context-sharing strategies work in multi-agent systems?

Most multi-agent systems use a combination of five strategies: shared trust boundaries, privacy-preserving tools, shared knowledge spaces, human-mediated requests, and selective approval workflows. Each approach trades off usefulness, engineering complexity, privacy exposure, and operational scalability.

1. Shared trust boundaries

A shared trust boundary gives an agent broad access within a defined function, team, or group. Trust boundaries alone aren't enough without the sandboxing layer underneath them (see how zero-trust sandboxing contains agent actions at runtime). An HR operations agent, for example, might access the same approved systems available to HR staff and answer questions for authorized users.

This approach is straightforward because permissions resemble existing SaaS access control. It is often a sensible starting point for IT, security, support, or engineering teams that already work from common systems. The limitation is that it creates another bounded silo. It does not automatically surface relevant context from other groups, and people must still decide which systems belong inside the boundary.

2. Privacy-preserving tools

Instead of exposing raw data, a tool can return a constrained result. For example, a relationship lookup could search permitted communications and return ranked connection strength rather than the contents of private messages.

This pattern can help teams answer questions such as who is best positioned to introduce a colleague to a contact at another company. The system can identify likely candidates, then request confirmation from the person whose relationship is involved. It is useful because it preserves more privacy than broad search access, but it requires deliberate tool design and clear disclosure policies.

3. Shared knowledge spaces

A shared repository documentation directory, architecture decision record (ADR) store, or team runbook repository gives coding agents a common place to retrieve reusable technical knowledge. Engineering teams can record verified debugging procedures, migration patterns, deployment practices, and recurring operational fixes directly within version-controlled codebases.

The most promising version is a policy-aware maintenance agent that regularly reviews new information inside private feature branches or workspace history and proposes or publishes material suitable for a shared repository space. For engineering teams, that could mean extracting a proven database profiling workflow, a resolved incident pattern, or an updated service runbook into the official docs.

This can compound over time. Each useful code or documentation contribution makes future coding agents and developers less dependent on rediscovering the same technical workaround. It also introduces a serious quality problem: if incorrect instructions enter shared memory and remain uncorrected, autonomous agents may repeatedly amplify those errors across subsequent pull requests.

4. Humans as information conduits

A human-mediated system asks people to authorize each request before their agent searches a private source or releases a result. This provides strong control but creates friction when a question must be sent widely to find the few people who hold relevant information.

For a narrow query across a large organization, this can become notification spam. Asking every employee whether they know a particular contact or possess a relevant document does not scale. Human approval should be reserved for decisions where the cost of exposure is high, not for every low-risk lookup.

5. Selective approval after private search

A more advanced model lets authorized agents search private sources without exposing findings, then asks only the relevant information owner for approval when a result needs to be shared or acted on.

For example, internal agents could determine which person has the strongest relationship with a prospective customer contact. Only that person would receive an approval request asking whether the relationship may be disclosed or whether an introduction should be drafted. This sharply reduces unnecessary interruptions, but it requires rigorous controls over what the search process can retain, reveal, and log.

Give coding agents durable project context.

Levr connects issues, acceptance criteria, test runs, and activity history so agents can work from the same live project state as the engineering team.

Explore agent-first project workflows

How should teams build a shared knowledge space safely?

Teams should treat shared agent memory as a governed knowledge product, not an unrestricted dumping ground. Start with low-sensitivity material, define publication policies, track provenance, support corrections, and make every automated contribution attributable to a source and decision path.

A useful shared space contains information that helps future work without exposing private data. Good early candidates include:

  • Repository-specific build, test, and deployment instructions.
  • Reusable debugging techniques and performance investigation workflows.
  • Architecture decisions that affect implementation choices.
  • Service ownership, runbooks, and incident response procedures.
  • Resolved defects and the tests that prevent recurrence.

Start with a contribution policy that separates information into three zones:

  • Low sensitivity: May be added automatically when it satisfies defined quality checks.
  • Review required: May be proposed by an agent but requires a named owner to approve publication.
  • Restricted: Must remain within its original system or team boundary.

The policy should be specific enough for a person to review and for an agent to apply consistently. “Do not share confidential information” is not enough. Define categories such as financial plans, personnel matters, customer identifiers, credentials, security findings, and unannounced product strategy.

Shared knowledge also needs lifecycle management. Attach source links, timestamps, owners, and confidence or review status where possible. Give people a way to correct, deprecate, or remove facts. A knowledge base that cannot forget is risky, especially when agents treat previous entries as authoritative context.

What can go wrong when agents work across information silos?

Cross-silo agent systems can fail through prompt injection, stale memory, accidental disclosure, weak approval logic, and poor auditability. Context poisoning is one entry point among several — see the full picture of AI agent security and prompt injection risks. These risks grow when agents ingest untrusted content, execute tools with broad permissions, or treat shared summaries as unquestioned facts.

Prompt injection is a central risk. An agent may ingest instructions embedded in a document, issue, email, webpage, or repository file. If the agent confuses untrusted content with valid instructions, it may disclose data, misuse a tool, or contaminate shared memory. The OWASP guidance on prompt injection recommends treating untrusted inputs separately from system instructions and limiting an agent’s permissions.

Knowledge poisoning is another persistent failure mode. A single incorrect entry can spread when agents repeatedly retrieve and summarize it. This is especially dangerous when the wrong fact concerns a customer commitment, service ownership, technical constraint, or compliance requirement. Every shared-memory design needs correction workflows and clear ownership.

Approval can leak information too. A request for permission may itself reveal sensitive facts. For example, asking someone to approve disclosure of a relationship with a recruiter could expose job-search activity, even if the system never shares the underlying email. Design approval prompts so they reveal only what is necessary.

Auditability cannot be optional. Even a privacy-preserving system needs a record of what policy allowed a search, which sources were consulted, who approved a disclosure, and what actions followed. Logs should be access-controlled, but organizations need a way to investigate unexpected behavior.

Model Context Protocol, or MCP, can standardize how coding agents connect to tools and project systems, but a protocol does not remove the need for access boundaries. The MCP authorization specification emphasizes the importance of controlled authorization when clients connect to protected resource servers.

Every Cross-Agent Access, Logged and Gated

When one agent pulls context from another team's repository, that boundary crossing needs a witness. Levr logs every cross-agent access request against its approval gate, so a lead can see exactly which agent asked for what, from where, and whether it was granted — before a poisoned document ever reaches a running agent.

Agentic Software Development | Control Plane | Manual & Automatic Verification Issue Tracking |Levr

Context doesn't cross a trust boundary silently. Levr's audit trail shows every request, every gate, and every approval.

How can engineering teams introduce privacy automation gradually?

Engineering teams should begin with low-risk context and explicit policies, then increase automation only after measuring quality, false disclosures, correction rates, and operational value. The safest path is progressive autonomy, not immediate unrestricted access across every system.

A practical rollout looks like this:

  1. Map information sources. Identify repositories, issue trackers, CI/CD results, runbooks, chat systems, and documents that agents may need.
  2. Classify sensitivity. Mark which data can be broadly shared, which needs owner review, and which remains restricted.
  3. Choose narrow workflows. Start with a clear use case such as publishing validated engineering runbooks or linking test failures to related issues.
  4. Use deterministic gates. Require concrete checks, such as test status, issue ownership, source attribution, or an approval record, before changing shared state.
  5. Review outcomes. Inspect what agents proposed, what was published, and what was later corrected or removed.
  6. Expand only with evidence. Broaden the low-sensitivity zone when the system demonstrates reliable behavior and the organization understands its failure modes.

One way to manage this in Levr is to define intent in natural language, let a coding agent work from an issue and its acceptance criteria, record automated verification, and keep human review at designated workflow gates. Because issues, tests, results, and activity share a control plane, the team can inspect why work moved forward and which agent or person performed each action.

That structure is valuable even when agents are not searching across private enterprise systems. The same discipline applies to project context: agents should retrieve current requirements, write against explicit acceptance criteria, run relevant tests, and leave an attributable history rather than relying on an ephemeral prompt.

Can multi-agent systems work across company boundaries?

Multi-agent collaboration across companies may create value where participants benefit from coordinated analysis, but it requires stronger consent, data minimization, policy alignment, and contractual governance than internal systems. External sharing should begin with tightly constrained use cases and clearly defined outputs.

Potential use cases include joint supply-chain planning, lending analysis, vendor operations, and shared incident coordination. The appeal is clear: multiple organizations may each hold part of the information needed to make a better decision.

The challenge is that each organization has separate legal obligations, security standards, commercial incentives, and definitions of sensitive information. A system that is appropriate inside one company may be unacceptable across a partner network.

Before enabling cross-company agent workflows, define:

  • Which questions the system may answer.
  • Which data categories may be searched, summarized, or disclosed.
  • Whether results are aggregate, ranked, anonymized, or source-identifying.
  • Which actions always require a human approval step.
  • How data retention, audit access, revocation, and incident response work.

Network effects are possible when more participants create more useful context. But the system only earns that benefit if participants trust the rules. Privacy automation should make collaboration safer and more efficient, not turn every shared workflow into an uncontrolled data exchange.

Technical Deep Dive FAQ

What is a multi-agent system?

A multi-agent system is a software architecture in which multiple agents perform distinct tasks, exchange information, use tools, or coordinate toward a shared outcome. In engineering workflows, one agent might plan work, another inspect a repository, another run tests, and another update project state. The architecture is useful when specialization improves reliability or throughput. However, it only works when agents have clear boundaries, trustworthy context, and a defined way to resolve conflicting information or actions.

What is agentic search?

Agentic search is a process where an agent actively retrieves, evaluates, and combines information from available tools or sources before answering a question or taking an action. Unlike a simple retrieval step, it may involve several searches, comparisons, and tool calls. The objective is to assemble the context needed for a specific decision. In multi-agent systems, agentic search becomes difficult because the most relevant information may be distributed across repositories, project tools, private documents, and restricted business systems.

Why is shared memory important for coding agents?

Shared memory prevents coding agents from treating every assignment as a fresh, isolated prompt. It can provide prior decisions, issue history, acceptance criteria, known constraints, related defects, and previous test results. This reduces repeated discovery work and helps agents behave consistently across runs. Shared memory should not be a loose collection of summaries. It needs provenance, recency signals, access controls, and a correction process, or outdated and incorrect context can become a recurring source of implementation errors.

How do you prevent stale facts in an agent knowledge base?

Prevent stale facts by attaching each entry to an authoritative source, recording when it was created or reviewed, assigning an owner, and defining expiration or review rules for volatile material. Agents should prefer source-linked documentation over unattributed summaries when there is a conflict. Teams also need an easy way to deprecate and delete entries. For high-impact knowledge, require review before publication and after major architecture, ownership, policy, or product changes. A searchable history helps investigate how an incorrect fact entered the system.

What should agents be allowed to share automatically?

Agents should automatically share only information that has been deliberately classified as low sensitivity and useful to a defined audience. Examples may include approved coding standards, public service runbooks, validated build instructions, and resolved technical patterns that contain no credentials or customer data. The exact boundary differs by organization. Start narrowly and use policy checks, source attribution, and logging. Information involving personnel, finance, customers, security, legal matters, or confidential strategy typically needs stronger restrictions or explicit human approval.

How can approval workflows avoid notification overload?

Approval workflows should request human input only when a system has identified a relevant owner and a meaningful disclosure or action is imminent. Avoid broadcasting a request to everyone who might have useful information. Use private search or constrained discovery where permitted, then route a narrowly worded approval request to the person responsible for the result. The request should disclose only the necessary context, explain the proposed action, and offer a clear approve, reject, or escalate option. Log the final decision and policy basis.

How does prompt injection affect multi-agent systems?

Prompt injection can affect multi-agent systems when one agent passes untrusted text, files, webpages, tickets, or tool output to another agent as context. Malicious or accidental instructions may then influence tool selection, data access, or shared-memory updates. Reduce the risk by separating untrusted content from governing instructions, limiting tool permissions, validating outputs before execution, and avoiding automatic publication of retrieved text. Agents should treat external content as evidence to analyze, not as commands to follow. Sensitive actions need deterministic controls beyond model judgment.

What should be logged in an agent-to-agent workflow?

Log the task or intent, participating agents, tools invoked, authorization context, sources consulted, summaries or outputs produced, policy decisions, approvals, and resulting actions. For coding workflows, also link work to issues, commits, pull requests, test runs, and deployment evidence when available. Logging must balance accountability with privacy, so raw sensitive data should not be copied into broadly accessible logs. The goal is to reconstruct why an agent acted, what information justified the action, and where an unexpected result originated.

How do project control planes help agentic development?

A project control plane gives coding agents and humans a shared operational record for work. Instead of placing requirements in one tool, test evidence in another, and agent activity in disconnected prompts, it links intent, issues, acceptance criteria, workflow gates, test results, and history. This makes context easier to retrieve and makes actions easier to review. In Levr, agents can work against the same live issues and tests as the team, while workflow states and quality gates define what must happen before work is complete.

Should multi-agent systems be fully autonomous?

Not by default. Autonomy should match the sensitivity and reversibility of the task. Low-risk actions, such as suggesting documentation improvements or running an existing test suite, may be suitable for high automation. High-impact actions, such as disclosing private information, changing production infrastructure, or publishing external communications, need stronger controls. A mature system supports different autonomy levels within one workflow: agents can investigate and prepare work automatically while humans approve the points where consequences become difficult to reverse.

Key Takeaways

Multi-agent systems become more useful when they make relevant context available without treating privacy as an inconvenience.

The strongest designs combine constrained access, durable shared knowledge, and explicit accountability.

  • Think context first: The important question is whether an agent has the right information before it acts.
  • Start with low sensitivity: Automate sharing of approved engineering knowledge before expanding into sensitive business data.
  • Keep memory correctable: Shared agent knowledge needs sources, owners, review, and deletion paths.
  • Use approvals selectively: Ask humans at meaningful disclosure and execution boundaries, not for every lookup.
  • Make actions traceable: Logs, workflow gates, and linked verification preserve accountability as autonomy increases.

The best agent networks do not maximize access. They maximize useful, policy-compliant context.

Further reading

Ship at agent speed

Give your coding agents a control plane, not just a prompt.

Levr connects your coding agents, including Claude Code, Cursor, Codex, and Copilot, to shared project context with issues, gates, test suites, and memory. Free tier available. No credit card required.

Levr provides shared context, attributable activity, workflow gates, and agent-ready project objects so humans and agents can operate from the same source of truth.

Get early access, it’s free

No credit card required during beta.