Protocol-Driven Agent Architecture

Building scalable agents requires decoupling the UI from the inference engine. The Codeex harness utilizes two primary protocols: the App Server protocol (managing UI-to-harness communication) and the Responses API (handling harness-to-inference communication). This architecture allows for an open ecosystem where developers can build custom interfaces or integrate with tools like Cloud Code or even game engines like Doom, while leveraging standardized capabilities like web search and image generation.

Context Management and Performance

To maintain performance and cost-efficiency in long-running agents, context management is critical. Codeex employs three specific strategies:

  • Deferred Tool Loading: Tools are marked as deferred and excluded from the initial context window, becoming available only via tool search to save tokens.
  • Dynamic Capping: Available skills are capped at 2% of the context window, with descriptions truncated as the window grows.
  • Websocket Mode: Moving from HTTP/Server-Sent Events to persistent WebSockets allows for stateful communication, sending only the delta of changes (e.g., tool call results) rather than re-transmitting the entire history.

Agentic Actions and Security

Agents require sophisticated interaction patterns to perform real-world tasks. Codeex uses a sandbox layer (utilizing seatbelt on macOS, bubblewrap on Linux, and a custom open-source sandbox for Windows) to execute file system and browser interactions.

To solve "approval fatigue" while maintaining security, the system implements Auto-Review. When an agent attempts a sensitive action (e.g., file deletion), it triggers a secondary, read-only "Auto-Review" sub-agent. This sub-agent evaluates the action against the user's original intent, the current transcript, and a risk taxonomy to decide whether to approve the action automatically or escalate it to the human user.

Long-Running Task Management

For tasks spanning hours or days, the harness manages state through:

  • Goal-Oriented Loops: Rather than long-form prompts, agents use concrete, verifiable goals. The harness injects continuation prompts until the agent calls an update_goal tool.
  • Auto-Compaction: The system automatically triggers context compaction, condensing long transcripts into a summarized state that preserves necessary information while keeping the context window performant for subsequent turns.