Codjent Sample App
Codjent (github.com/ijaidev/gojent/codjent) is an ACP-first local coding agent built on the Gojent runtime to exercise the loop, typed tools, MCP client, policies, managed subagents, and persistence end to end. Codjent is a sample application, not a supported product—it omits authentication, multi-tenant isolation, and hosted deployment features, and exists as a concrete reference you can inspect or copy from.
Install and run
Codjent lives in its own Go module (codjent/) and requires Go 1.25 or newer:
go install github.com/ijaidev/gojent/codjent/cmd/codjent@latest
codjent # open the Bubble Tea provider & model manager TUI
codjent acp # serve ACP v2 over stdio for external clients such as T3 Code
Or run directly from a repository checkout:
just --justfile codjent/justfile run # interactive provider manager TUI
just --justfile codjent/justfile acp # ACP v2 stdio server
On first run, press a in the TUI to configure a provider preset (or c for a custom OpenAI/Anthropic-compatible endpoint), paste an API key, review pre-selected models, and press Ctrl+S to save to SQLite. For backwards compatibility, setting GEMINI_API_KEY or GOOGLE_API_KEY seeds a Google provider automatically.
Key capabilities
- Bubble Tea provider & model manager (
codjent): Embedded preset and model catalog frommodels.devand OpenRouter (OpenAI Responses/Chat Completions, Anthropic, Google Gemini, OpenRouter, OpenCode, DeepSeek, Groq, xAI, Mistral, Ollama, LM Studio), live/modelsdiscovery (Ctrl+F), manual model entry (Ctrl+A), masked write-only keys, static/dynamic custom headers, and cross-process SQLite catalog sync (PRAGMA data_version). - ACP v2 stdio server (
codjent acp): Newline-delimited JSON-RPC 2.0 over stdin/stdout (diagnostics on stderr) supportinginitialize,session/new,session/set_config_option,session/prompt(text, PNG/JPEG/WebP images, resources),session/cancel,session/list,session/resume,session/fork,session/delete, andsession/close. - Workspace tools & approvals: Sandboxed filesystem read/write/edit/list/glob/grep tools, foreground-to-background
execute_commandwith live output streaming (terminal_update/terminal_output_chunk), client-supplied stdio/HTTP MCP servers, workspace skills (<root>/.agents/skills/*/SKILL.md),/compactsummarization, andsession/request_permissionapproval gates with inline diffs.
Subagents, thread lineage, and ACP v2 sessions
Every root session in codjent acp wires a session-scoped tools/subagent host backed by SQLite thread persistence:
- Persisted thread lineage: An additive, idempotent SQLite migration adds
parent_thread_id,subagent_profile,subagent_description, andsubagent_branch(indexed byidx_threads_parent) tothreads. Child threads are omitted by default from top-level listings (session/list,ListThreads), andsession/delete(DeleteThread) recursively deletes all descendant threads and messages in SQLite. - Built-in profiles and dynamic definition: Codjent defines two built-in Go profiles—
explorer(read-onlyread_file,list_files,glob_files,grep_files,AllowNested: false) andworker(filesystem, search, and managedexectools,AllowNested: true)—plus capability-attenuated runtimesubagent_definecapped atworkertools and 16 dynamic profiles per session. Workspace or home-directory agent files are not loaded. - Git worktree isolation: Subagents using
workspace: "worktree"run inside isolated git worktrees and temporary branches viasubagent.GitWorktreeProvider(keepingadditionalDirectoriesisolated), with per-worktreeexecmanagers closed on session shutdown andsubagent_cleanupgated inaskmode. - Native ACP v2 subagent sessions:
- Child sessions are announced to their immediate parent via
subagent_updatebefore child updates or tool links, receive prompts viasession_message, and are linked fromsubagent_spawn/subagent_send/subagent_wait/subagent_status/subagent_canceltool results viatype: "session"content items (both live and duringsession/resumereplayFrom: "start"). - Clients can cancel an active child session directly with
session/cancel, while client-initiatedsession/prompt,session/resume,session/fork,session/delete,session/close, andsession/set_config_optiontargeting a child session are rejected with JSON-RPC-32602. - Under
askmode, mutating tool calls inside child and nested grandchild runs triggersession/request_permissionon the child’ssessionIdwhile inheriting parent/ancestorplanmode blocks and session-memory rejections.
- Child sessions are announced to their immediate parent via
Internal layout and configuration
Codjent follows the same one-way dependency rules as the rest of Gojent:
codjent/internal/app: Thread/run lifecycle, approval gate, subagent host (NewSessionSubagents), event log, and transcript persistence contract.codjent/internal/store/sqlite:app.Storeand provider catalog persistence (usingmodernc.org/sqlite).codjent/internal/provider: Provider seam, SQLite-backed dynamic catalog, and embedded/cached presets.codjent/internal/acp: Stdlib-only ACP v2 stdio server callingapp, never imported byapportui.codjent/internal/tui: Bubble Tea UI, never imported byapporacp.
Environment variables such as CODJENT_DATA_DIR, CODJENT_WORKSPACE, CODJENT_PROVIDER, CODJENT_MODEL, CODJENT_ACCESS_MODE, and CODJENT_MAX_STEPS configure defaults; see codjent/README.md for the full variable table and ACP command flags.