Inspiration
AI coding agents are becoming increasingly capable, but they often begin complex tasks with an inefficient reasoning environment: too much context, too many tools, and unclear permission boundaries. This can increase latency, distract the model, and make agent behavior harder to understand or control. We built Cognition Runtime around a simple idea: optimization should happen before reasoning begins. Instead of replacing the host model or routing prompts through another AI provider, Cognition Runtime prepares a focused reasoning environment for ChatGPT, Codex, and Claude Code. It recommends the minimum useful context and capabilities while preserving the original prompt, host governance, and user control.
What it does
Cognition Runtime is a Go-based pre-reasoning context optimizer for AI agents. Before the host model starts a non-trivial task, it: analyzes the request’s intent, complexity, and risk; ranks relevant workspace context; filters sensitive, generated, binary, and unrelated files; selects only the tools needed for the task; evaluates model and permission requirements; produces an immutable reasoning package with integrity metadata; explains the recommendation in the user’s language. Safe reductions can be applied without expanding capabilities. If a recommendation materially changes the reasoning environment, Cognition Runtime presents exactly two choices: Use the Cognition Runtime recommendation Continue normally The runtime never silently expands permissions. If optimization or confirmation is unavailable, it fails open and allows the host to continue normally. Cognition Runtime supports: ChatGPT through a public HTTPS MCP server and Apps SDK-compatible component; Codex through a native plugin, skill, and local MCP server; Claude Code through a native plugin, MCP server, and fail-open UserPromptSubmit hook; Standalone usage through a cross-platform CLI and Docker deployment.
How we built it
We implemented Cognition Runtime as a deterministic, Go-only product runtime shared across every integration. The main architecture includes: a recommendation engine for intent, complexity, risk, and capability analysis; a workspace inspector with sensitive-file and generated-content filtering; an immutable reasoning package with SHA-256 integrity metadata; a shared MCP server exposing the stable tools:recommend_context present_recommendation_custom present_recommendation resolve_context
an HTTP MCP transport for hosted ChatGPT integrations; a stdio MCP transport for local Codex and Claude Code plugins; an Apps SDK-compatible widget for displaying structured recommendations; an in-memory state store with expiration and idempotent resolution; cross-platform release packaging for macOS, Linux, and Windows. The public HTTP service exposes only: POST /mcp GET /healthz Hosted mode cannot inspect local workspaces, does not persist raw prompts, and does not require provider API keys. We used Codex extensively throughout development. Codex accelerated the migration from an early prototype to a Go-only runtime, MCP integration, native confirmation flow, localization, automated testing, release packaging, security review, and installed-plugin verification. GPT-5.6 contributed to evidence-backed planning, technical review, and verification. Hung Le made the key product and engineering decisions, including the optimizer-focused scope, Go-only runtime, fail-open policy, two-choice user experience, and security boundaries. Challenges we ran into One of the largest challenges was supporting three different AI hosts without creating three separate implementations. ChatGPT, Codex, and Claude Code expose different plugin, MCP, UI, and lifecycle capabilities. We addressed this by keeping the recommendation engine and MCP contract host-independent, while limiting each adapter to the integration features officially available in that host. Another challenge was maintaining user control without interrupting every request. We needed to distinguish between safe context reduction and material environment changes. The resulting design automatically handles safe reductions but requires explicit confirmation before applying changes that affect tools, models, or permission boundaries. Cross-process recommendation state was also challenging. A recommendation may be created by one MCP request and presented or resolved by another. We implemented expiring state, immutable recommendation identifiers, and idempotent resolution so repeated calls remain safe and predictable. Additional challenges included: avoiding unsupported claims of universal prompt interception; creating a consistent confirmation experience across different hosts; safely inspecting local repositories without reading sensitive files; preventing the hosted service from accessing local workspace data; packaging native plugins with embedded binaries for multiple operating systems; removing internal workflow and provider-gateway code before publishing; scanning the repository and Git history for secrets; keeping the public deployment stateless, rate-limited, and key-free. Accomplishments that we're proud of We are proud that Cognition Runtime became a focused, public developer tool rather than another model proxy or chat interface. Key accomplishments include: one deterministic Go core shared across ChatGPT, Codex, and Claude Code; no OpenAI, Anthropic, Google, xAI, or Alibaba provider key requirement; transparent recommendations instead of hidden prompt modification; exactly two clear confirmation choices; fail-open behavior that never blocks the host unnecessarily; local workspace ranking with sensitive-file filtering; immutable reasoning packages with SHA-256 integrity metadata; native MCP elicitation and a structured recommendation component; idempotent recommendation resolution with automatic expiration; public and local MCP transports; prebuilt plugin packages for macOS, Linux, and Windows; Docker and Render deployment support; automated tests, race detection, vetting, plugin validation, release checksums, and secret scanning; an estimated benchmark result of 88% context reduction with 0% estimated quality loss for the acceptance scenario. We are also proud that the complete public runtime is written in Go and distributed under the MIT License.
What we learned
We learned that improving an AI agent does not always require another model call. Deterministic preparation can remove irrelevant context, reduce unnecessary capabilities, and make the reasoning environment easier to understand. We also learned that host limitations should shape product claims. Codex does not require us to pretend that universal global prompt interception exists. Explicit activation through a plugin, skill, or MCP tool is more transparent and easier to test. The project reinforced several important principles: context quality is often more important than context quantity; optimization should not silently expand permissions; users need understandable choices, not internal implementation details; fail-open behavior is essential for infrastructure placed before reasoning; a shared protocol is more maintainable than host-specific product logic; hosted and local integrations require different privacy boundaries; estimates must be clearly labeled and never presented as measured provider performance; release packaging and clean-environment testing are part of the product, not an afterthought. Most importantly, we learned that a pre-reasoning layer can remain useful without owning the conversation, replacing the host model, or collecting provider credentials. What's next for Cognition Runtime The next phase will focus on stronger host integrations and evidence-based optimization quality. Planned improvements include: deploying and monitoring the public ChatGPT MCP endpoint; expanding real-world benchmark scenarios across different repository sizes and task categories; comparing estimated context reduction with measured latency and token usage; improving semantic workspace ranking while preserving deterministic and privacy-conscious behavior; adding clearer explanations for why each context source or tool was selected; supporting configurable organization-level security policies; expanding localization beyond English and Vietnamese; improving plugin installation and automatic update workflows; adding richer observability without logging raw prompts or reasoning packages; validating additional MCP-compatible AI development environments; collecting developer feedback to refine the recommendation thresholds and two-choice experience. Our long-term goal is to make Cognition Runtime a lightweight, open standard for preparing safe and focused reasoning environments before AI agents begin their work.
Log in or sign up for Devpost to join the conversation.