A fact in progress: building your own agent foundation is becoming the worst cost-benefit trade in software.
Just last week (2026-08-19), OpenAI announced "Codex as a platform," formally opening Codex Harness's three integration entry points to third parties (see OpenAI Hands Over the Agent's Engine). Anthropic's Claude Agent SDK, Google's Gemini CLI headless mode, xAI's Grok Build headless mode, and the open-source community's OpenHands were already sitting at the same table. Four official vendors plus one community project - all of them let you embed "an agent that works, uses tools, and runs its own loop" directly into your product.
This comparison lines up the five contenders on one question: when you're embedding an agent into your own system (not using it as a chat tool), which one do you pick? Scope note: star counts and repo status are GitHub API snapshots (2026-08-22); this is a representative comparison based on each vendor's official README and docs, not a long-term hands-on bake-off; selection conclusions are for reference, with official docs as the authority.
1. The Basics: Who Are the Five
| Option | Repo | Stars | License | Language | Integration entry points |
|---|---|---|---|---|---|
| OpenAI Codex Harness | openai/codex | 111,646 | Apache-2.0 | Rust | codex exec / TS+Python SDK / app-server (JSON-RPC) |
| Anthropic Claude Agent SDK | claude-agent-sdk-python | 7,951 (Python) / 1,711 (TS) | MIT | Python / TS | query() async stream / TS SDK |
| Google Gemini CLI | google-gemini/gemini-cli | 106,608 | Apache-2.0 | TypeScript | -p headless + --output-format json / ACP mode |
| xAI Grok Build | xai-org/grok-build | 25,860 | Apache-2.0 | Rust | headless mode / Agent Client Protocol |
| OpenHands | OpenHands/OpenHands | 84,748 | MIT | TypeScript | event-stream API / self-hosted platform |
Three sentences on each contender's personality:
- Codex Harness: the most complete platform story. Three entry points layered by integration depth (one command / SDK / JSON-RPC protocol service); threads persist in
~/.codex/sessionswith breakpoint resume; the SDK natively supports JSON Schema structured output. - Claude Agent SDK: the finest permission model. The Python package bundles the Claude Code CLI (
pip install claude-agent-sdkworks out of the box);allowed_toolsallowlisting plus thecan_use_toolcallback hands approval decisions back to your code - the most careful tool-granularity control of the five. - Gemini CLI: the smoothest scripting story. Non-TTY environments or the
-pflag enter headless;--output-format jsonreturns a single object with token stats; streaming mode emits a JSONL event stream (init/message/tool_use/tool_result/result); exit codes even give "turn limit exceeded" its own number (53). An ACP mode covers editor integration. - Grok Build: the newest entrant (open-sourced 2026-07-14, 25k stars in a month). A Rust full-screen TUI coding agent with interactive / headless / ACP modes, source periodically synced from the SpaceXAI monorepo.
- OpenHands: the only one that open-sources "the whole platform." Web UI, sandbox, and event stream included. If you want a self-hosted, complete agent platform rather than an embeddable component, it is the only option.
2. Capability Comparison: The Six Things That Actually Matter When Embedding
| Capability | Codex Harness | Claude Agent SDK | Gemini CLI | Grok Build | OpenHands |
|---|---|---|---|---|---|
| Structured output | ✅ JSON Schema (outputSchema) | ⚠️ parse message stream yourself | ✅ --output-format json | ⚠️ parse headless output | ✅ event stream |
| Streaming events | ✅ runStreamed() event generator | ✅ async iterator | ✅ JSONL event stream | ✅ headless stream | ✅ event bus |
| Thread persistence / resume | ✅ resumeThread() | ✅ session resume | ✅ session management | ⚠️ not documented | ✅ |
| Permission / approval control | ✅ sandbox modes + approval config (incl. audit-grade filesystem rules) | ✅ allowed_tools + can_use_tool (finest) | ✅ approval modes + enterprise controls | ✅ sandbox | ✅ sandbox + confirmation |
| Protocol-level access | ✅ app-server (JSON-RPC 2.0, stdio/ws/unix) | ⚠️ no standalone protocol service | ✅ ACP | ✅ ACP | ⚠️ platform API |
| Free tier | model billed separately | model billed separately | free tier + API | model billed separately | bring your own key, framework free |
Two judgments that are easy to miss:
- "Repo stars" and "can I commercialize" are different questions. The Claude Code main repo has the most stars (142,324) but carries no open-source license (source-available); the Claude Agent SDK, meanwhile, is cleanly MIT. Conversely, the Codex main repo is Apache-2.0. Before embedding, read the license, not the star count.
- "Harness is open source" and "models are free" are different questions. All five open-sourced the execution framework; model calls bill through each vendor's API. What you save is the two-to-three months of engineering time to build your own foundation - not the token bill.
3. Choose by Scenario: Five Routes
- Just want one-off tasks in CI / cron:
codex execorgemini -p. One command, zero refactoring - don't reach for an SDK. - Your product is TS/Python and you want to call the agent like a function: Codex SDK (structured output + thread resume out of the box) or Claude Agent SDK (finest permission control). The tiebreaker: if you care more about "output discipline," pick Codex; if more about "action controllability," pick Claude.
- The agent is your product, with custom UI, approval flows, event streams: Codex
app-server(JSON-RPC 2.0, schema generated viagenerate-json-schema) or ACP (Gemini CLI / Grok Build). - Want full self-hosting with no single-vendor model gateway: OpenHands, the only whole-platform open-source option.
- Heavy terminal TUI users: Grok Build - the Rust full-screen interactive experience is the most "native" of the five.
4. Three Traps to Avoid
- Don't mistake "embeddable" for "safe once embedded." All five offer sandboxes and approvals, but defaults lean permissive. OpenAI's own eval sandbox was breached from the inside by its own agent just last week (see OpenAI Hits the Brakes); least privilege, approval gates, and audit logs are your job (see the Agent Guardrails Deployment SOP).
- Don't ignore protocol lock-in cost. Choose
app-serveror ACP and your event-handling layer couples deeply to that protocol; the SDK layer couples less, the CLI layer least. Every level up in integration depth doubles migration cost - start at the shallowest level that works. - Don't build a general-purpose agent foundation in 2026. Not a joke: models, protocols, and benchmarks are all still moving; five full-time official teams are competing on exactly this. Your homegrown version becomes a maintenance burden. The self-build value has moved up to the business layer (approvals, metering, domain tools), not the execution layer. For the Codex entry-point landing path, see our Codex Harness Integration SOP.
One-line closer: freeload the foundation from the vendors, and spend the engineering time you save on the reins - that's where your product actually differs from everyone else's.
FAQ
Q1: Claude Code has the most stars - why does the table say its license is "none"? A1: The anthropics/claude-code main repo (142,324 stars) ships no open-source license - it's source-available: readable, but not freely commercializable. What's genuinely MIT-licensed are claude-agent-sdk-python (7,951 stars) and the companion TS repo. Embed on the MIT SDK, and don't copy code from the main repo.
Q2: What's the relationship between Codex's app-server and MCP?
A2: Same communication style (JSON-RPC 2.0), different jobs. MCP is the protocol for "a model connecting to external tools"; app-server is the protocol for "an external program connecting to the Codex agent" - one is the agent's hands, the other is the agent's cockpit. app-server supports stdio / WebSocket / Unix socket transports and provides generate-json-schema to emit version-matched schemas.
Q3: All five open-sourced their Harness - why do you say model costs don't go away? A3: What's open is the execution framework (context management, tool scheduling, loop, sandbox); model inference still bills through each vendor's API. OpenAI itself draws the line explicitly: the Harness and integration layer are open, while model access, account quota, and hosting are a different matter.
Q4: What's the lowest-cost embedding path for a small team without platform engineers?
A4: Start at the shallowest CLI layer: codex exec or gemini -p in CI - one line of shell completes the integration. Upgrade to the Codex SDK when you need structured output and thread resume; touch app-server / ACP only when you're building custom UI and approval flows. Every level doubles migration cost; always start at the lowest level that suffices.
Q5: What's the fundamental difference between OpenHands and the other four? A5: The other four hand you "components to embed in your product"; OpenHands hands you "an entire self-hosted platform" - web UI, sandbox, event stream, multi-agent, all included (84,748 stars, MIT). The one-line test: if the agent is a feature of your product, pick one of the four vendors; if you're operating an agent platform, pick OpenHands.
References
- GitHub API snapshots (2026-08-22): openai/codex (111,646★ Apache-2.0), anthropics/claude-code (142,324★ no license), anthropics/claude-agent-sdk-python (7,951★ MIT), google-gemini/gemini-cli (106,608★ Apache-2.0), xai-org/grok-build (25,860★ Apache-2.0), OpenHands/OpenHands (84,748★ MIT)
- openai/codex repo docs:
sdk/typescript/README.md,sdk/python/docs/getting-started.md,codex-rs/app-server/README.md - claude-agent-sdk-python README: query() usage, the allowed_tools / can_use_tool permission model
- gemini-cli docs:
docs/cli/headless.md(output formats, JSONL events, exit codes),docs/cli/acp-mode.md - grok-build README: TUI / headless / ACP modes, the monorepo sync mechanism
This is a representative comparison (based on official docs and API snapshots as of 2026-08-22), not a hands-on bake-off; selection should follow each vendor's official documentation.