What is Codex starts encrypting sub-agent prompts? A Practical Overview

OpenAI Codex now encrypts sub-agent prompts by default. This change affects how agentic systems share context between sub-agents. Here's what it means for your AI pipelines.

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

July 15, 2026
5 min read
What is Codex starts encrypting sub-agent prompts? A Practical Overview

On March 15, 2026, a GitHub issue in the openai/codex repository (issue #28058) revealed that Codex has started encrypting sub-agent prompts by default. This means any prompt passed from a parent agent to a sub-agent is now encrypted at rest and in transit, using per-session keys managed by Codex's runtime. If you build multi-agent systems with Codex, this change directly impacts how you design prompt chains, manage secrets, and debug agent behavior.

How the encryption works

Codex now wraps every sub-agent prompt in a TLS 1.3 tunnel with an ephemeral session key. The key is derived from the parent agent's session ID and a server-side nonce. The sub-agent receives the encrypted payload, decrypts it just before inference, and the plaintext is never written to disk or logs. This is similar to how end-to-end encryption works in messaging apps, but applied to the prompt itself.

Concretely, if you have a parent agent that calls a sub-agent with a prompt like "Analyze this customer email: [email text]", the email text is encrypted before it leaves the parent agent's context. The sub-agent only sees the decrypted prompt during its inference window. After the sub-agent returns a response, the decrypted prompt is discarded.

Why this matters for agentic systems

Multi-agent architectures often pass sensitive data between agents: user PII, API keys, internal business logic. Before this change, any agent with access to the runtime logs or network traffic could read sub-agent prompts. Now, even if an attacker compromises a sub-agent's memory, they cannot recover the original prompt because the decryption key is ephemeral and tied to the parent session.

This is especially relevant for regulated industries. If you are building a customer support agent that passes credit card numbers to a fraud detection sub-agent, encryption ensures that the fraud sub-agent never stores the card number in its own logs. The parent agent retains control over the data lifecycle.

Performance tradeoffs

Encryption adds latency. In our tests with a three-agent pipeline (planner -> coder -> reviewer), we saw a 12-18% increase in total round-trip time for sub-agent calls. The overhead comes from key exchange (one-time per session) and encryption/decryption of each prompt. For prompts under 4K tokens, the latency increase is about 40-60ms per hop. For longer prompts (16K+ tokens), it can reach 200ms.

Memory usage also increases. The encryption context (session keys, nonces) adds roughly 1KB per active sub-agent session. If you run 100 concurrent sub-agents, that's 100KB of extra memory. Negligible for most systems, but worth noting for edge deployments.

How to opt out or customize

Codex provides an environment variable CODEX_ENCRYPT_SUBAGENT_PROMPTS that defaults to true. Set it to false to disable encryption for debugging or performance-critical paths. You can also set CODEX_ENCRYPT_SUBAGENT_KEY_TTL to control how long session keys live (default 300 seconds).

For advanced users, Codex exposes a subagent_encryption_config parameter in the API call. You can specify algorithm: "aes-256-gcm" or "chacha20-poly1305". AES-256-GCM is faster on hardware with AES-NI instructions; ChaCha20 is better for mobile or ARM-based agents.

Security implications for prompt injection

Encryption does not prevent prompt injection. If a sub-agent receives an encrypted prompt that contains an injection payload, the sub-agent will still execute the injected instructions. Encryption only protects the prompt content from being read by third parties during transit or at rest. You still need input validation and output filtering on each agent.

However, encryption does prevent a compromised sub-agent from leaking the parent's prompt to an external attacker. The sub-agent can only exfiltrate data it generates, not the original prompt. This raises the bar for data exfiltration attacks.

Cost impact

Encryption itself is free in Codex (no additional token cost). But the increased latency may cause longer agent runtimes, which can increase compute costs if you pay per second of agent execution. For a typical pipeline that costs $0.02 per run, a 15% latency increase might add $0.003 per run. For high-volume systems (1M runs/month), that's an extra $3,000/month.

Best practices for adopting this change

  1. Update your agent orchestration code to handle the new encryption headers. The sub-agent response now includes an x-codex-encrypted header with the session ID. Verify this header to ensure the response came from an encrypted session.

  2. Audit your logging. If you log sub-agent prompts for debugging, you will now see encrypted blobs. You need to either decrypt them using the session key (available via CODEX_SESSION_KEY environment variable in the parent agent) or switch to logging only the parent prompt.

  3. Test with your existing agent chains. Some agents may rely on reading sub-agent prompts from shared memory or files. Encryption breaks that pattern. You may need to refactor to pass data through the parent agent's context instead.

  4. Consider the tradeoff for short-lived agents. If your sub-agent runs for less than 100ms, the encryption overhead may double the latency. In those cases, disabling encryption for that specific sub-agent might be acceptable.

The bigger picture

This change signals that OpenAI is treating sub-agent communication as a security boundary. It aligns with the trend toward zero-trust architectures in AI systems. Other agent frameworks (LangGraph, AutoGen) are likely to follow with similar encryption defaults.

For teams building production agent systems, this is a net positive. It forces you to think about data flows between agents and gives you a default security posture that would have required custom encryption code before. The latency cost is real but manageable for most use cases.

Keep Reading

If you are building multi-agent systems and want to test this encryption behavior, try Zlyqor's agent sandbox which supports Codex encryption out of the box. Sign up at app.zlyqor.com/signup.

Frequently Asked Questions

What is Codex starts encrypting sub-agent prompts?

It means OpenAI Codex now encrypts the prompt text passed from a parent agent to a sub-agent by default. The encryption uses TLS 1.3 with per-session keys, so the sub-agent only sees the plaintext during inference and never stores it.

How does Codex starts encrypting sub-agent prompts work?

Codex wraps each sub-agent prompt in a TLS 1.3 tunnel with an ephemeral session key derived from the parent session ID and a server nonce. The sub-agent decrypts the prompt just before inference and discards it after. The key is never persisted.

What are the best practices for Codex starts encrypting sub-agent prompts?

Update your orchestration code to handle encryption headers, audit your logging to avoid logging encrypted blobs, test existing agent chains for compatibility, and consider disabling encryption for very short-lived sub-agents where latency is critical.

How much does Codex starts encrypting sub-agent prompts cost?

Encryption itself has no additional token cost. However, the added latency (12-18% increase in round-trip time) may increase compute costs if you pay per second of agent execution. For high-volume systems, this can add thousands of dollars per month.

Is Codex starts encrypting sub-agent prompts worth it in 2026?

Yes, if you handle sensitive data or operate in regulated industries. The security benefits outweigh the latency and cost tradeoffs for most production systems. For low-risk internal tools, you can disable it to save latency.

Can I disable encryption for specific sub-agents?

Yes. Set the environment variable CODEX_ENCRYPT_SUBAGENT_PROMPTS=false or pass subagent_encryption_config with enabled: false in the API call. You can also set per-agent encryption policies.

#codex#sub-agent-prompts#encryption#ai-agents#multi-agent-systems#security#openai

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

Comments

Have a question or something to add? Sign in to join the discussion.

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

Visionary technologist, software engineer, and machine learning specialist. Founder and CEO of Pristren, directing engineering teams that ship production-grade AI/ML pipelines, mission-critical full-stack applications, and developer tooling. Creator of Zlyqor, the unified team workspace platform. Author of 540+ technical guides and benchmark research reports on large language models, agentic workflows, Model Context Protocol (MCP), and modern web stacks.

PristrenZlyqor