8000 GitHub - discord9/e-agent: A Rust coding agent with async subagents, goal-driven continuous execution, and terminal and web UIs. · GitHub
[go: up one dir, main page]

Skip to content
discord9Public

About

A Rust coding agent with async subagents, goal-driven continuous execution, and terminal and web UIs.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

e-agent

e-agent is a Rust coding agent with async subagents, goal-driven continuous execution, and terminal and web UIs. It is a small, single-crate program that streams requests to OpenAI-compatible /chat/completions APIs or the ChatGPT Codex /responses API, executes the model's requested workspace tools one at a time, returns results to the model, and prints its final answer.

Use it as a one-shot CLI command, an interactive terminal UI (the default with no prompt in a terminal), or a line-based REPL. e-agent web starts the local web UI and HTTP API. SQLite is the default session backend; JSONL and GreptimeDB are selectable in [session] (see SQLite session backend). The built-in tools cover workspace files, persistent notes, shell and background work, and main-session delegation. Background and subagent completion notifications are delivered to the session when they finish. A human can explicitly arm goal continuation with /goal continue [N]; active goals and restarts never arm it. See Session goals for the full behavior. Local stdio MCP servers can optionally add tools.

Quick start

Install a Rust toolchain with Cargo, configure a provider in Run, then from this repository checkout run one of these commands, replacing /path/to/workspace with the workspace the agent should use:

cargo run -- --workspace /path/to/workspace "inspect src/main.rs and explain it" # one prompt
cargo run -- --workspace /path/to/workspace --repl                                # line-based REPL
cargo run -- --workspace /path/to/workspace web                                   # web UI at http://127.0.0.1:8766

With no prompt, cargo run -- --workspace /path/to/workspace opens the terminal UI when stdout is a terminal.

The toolchain is pinned in rust-toolchain.toml (1.99.0); an inherited RUSTUP_TOOLCHAIN overrides it, so unset it if the build picks the wrong compiler.

Run

Create $XDG_CONFIG_HOME/e-agent/config.toml (falling back to ~/.config/e-agent/config.toml):

default = "kimi/k3"

[providers.kimi]
base_url = "https://api.kimi.com/coding/v1"
api_key_file = "kimi-key"          # or api_key_env = "KIMI_API_KEY"

[models."kimi/k3"]
model = "k3"
reasoning_effort = "high"          # provider-specific pass-through
vision = true                      # default; a text-only model sets false

vision defaults to on, so a profile written for a text-only model must set vision = false or its requests will carry images — see the upgrade note before reusing an existing config.

A provider needs exactly one of api_key_file or api_key_env; with neither it is treated as an unauthenticated local endpoint (vLLM, Ollama, llama.cpp) and requests omit Authorization. Provider names are inferred from the prefix before /. deepseek_compat = true opts a profile into the DeepSeek Chat thinking-mode wire (persisted reasoning is replayed on tool-call turns); everything else keeps the standard wire where reasoning is display-only.

The keys most configurations touch:

Key Meaning
default profile used when none is given
[providers.<name>].base_url API root, e.g. https://api.openai.com/v1
...api_key_file / api_key_env credential source, exactly one
[models."<p>/<n>"].model wire model name
reasoning_effort optional pass-through (low/high/max are common)
thinking enable provider thinking mode where supported
context_window token budget used for compaction
vision allow image input (default true; a text-only model sets false)
deepseek_compat DeepSeek Chat reasoning-replay contract
[sandbox].enabled run bash inside bubblewrap
[sandbox].network / workspace_writable defaults for that sandbox
[sandbox].writable_paths / readable_paths extra mounts
[session].backend sqlite (default), jsonl, or greptime
[roles] role → model profile routing
[bash].timeout_secs, [background].timeout_secs command timeouts

A workspace-level .e-agent/config.toml may add or override models, roles, MCP servers, [bash], and [background]; it cannot define providers or the session backend. --model, --base-url, and --profile override the file for one run.

Safety boundaries

The workspace and configured external capabilities constrain only the agent's file tools, and they are not a process sandbox. Relative paths use the workspace; absolute paths require an authorized external root, matched by the configured logical destination (the canonical source backs the capability; the input path is never canonicalized). Reads need a readable root, writes and edits need a writable one, and a read-only winner rejects a writable operation outright rather than falling back to a broader writable root while an exact read-only file denies only itself (see the sandbox policy rules above). Directory capabilities permit symlinks that stay inside their root and reject symlink escapes. Exact-file capabilities use a durable handle opened at startup, so file tools keep addressing the original inode if the trusted host renames or replaces that pathname (Bash resolves the pathname on each invocation) — keep configured roots stable for the run. Delegated custom workspaces must be canonical directories inside the startup workspace or an authorized writable external directory; read-only and exact-file capabilities cannot be rerooted, and configured alias destinations never extend reroot. Capabilities do not constrain hardlink inode origins or hardlink aliases to the protected project policy file, do not make read/edit sequences atomic, and do not isolate the agent process.

bash runs /bin/bash -lc with the workspace as its current directory. By default it is not sandboxed: commands can access files outside the workspace, environment variables, and the network. On Unix, timed-out commands are killed as a process group; on non-Unix platforms only the direct child is killed. stdout and stderr are each captured up to 64 KiB, then drained and marked as truncated. A bash child's stdin is the null device (Stdio::null(): /dev/null, NUL on Windows), never the agent's own descriptor, so a command that reads stdin gets EOF instead of blocking until its timeout on a terminal or a pipe nobody will ever write to. run_rust does the same.

Process containment (sandboxed bash): every sandboxed command runs in its own PID namespace, one instance per command. setsid and nohup change a process's session and process group, not its PID namespace, so a setsid nohup <daemon> & child cannot outlive the instance: when the instance's PID 1 exits, the kernel terminates every remaining member of that namespace. The same holds for a cancelled or timed-out command — the tool kills the bwrap process group, bwrap's own child is that PID 1 and dies with it (--die-with-parent), and the rest of the namespace dies with the init. Neither mechanism reaches a setsid child on its own (PDEATHSIG covers only bwrap's direct child, a process-group kill only one group/session), which is exactly why the namespace lifetime, not a cleanup step, is the boundary. Each command also gets a fresh namespace, so no process is ever shared between commands. Without [sandbox] enabled = true there is no process containment at all: setsid nohup <daemon> & leaves a process on the host that no cancel can reach and that get_background_tasks never showed.

web_fetch (the default fetch_provider = "local") performs its HTTP GET in this process, so it has exactly the same network reach as bash. There is no public-only destination filter: filtering one tool while the shell it sits next to can reach the same hosts is theatre, so the fetch reaches whatever the process reaches.

Optional shell restriction is available when [sandbox] enabled = true is set. On Linux/macOS this uses bubblewrap (bwrap) as described below. On Windows, the write-sandbox MVP is an accident-prevention mechanism, using a restricted primary token and stable synthetic capability ACEs. It restricts writes to the workspace (only when workspace_writable = true) plus explicit writable_paths; workspace_writable = false grants no workspace write ACE, and readable_paths never grants write access. TEMP/TMP, HOME, Cargo/NuGet, and engine caches are not implicitly writable.

The Windows MVP is not complete filesystem isolation: it does not restrict reads or network access, and network = false is rejected before launch. Except for the explicitly stripped credential variables (EXA_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, MOONSHOT_API_KEY, and KIMI_API_KEY), parent-process environment variables remain visible to the child process; this is not read or secret isolation. Locations already writable through Everyone or the current logon SID, including some public locations, may remain writable.

Only existing canonical directory paths on fixed local NTFS volumes are accepted: UNC/device paths, non-directory roots, symlinks/reparse points, NULL DACLs, and case-sensitive roots are rejected. The first run (or a versioned ACE upgrade) of each write root scans its tree without following links; later commands skip that scan because the exact current-version ACE is installed. The ACE grants create/overwrite plus child rename/delete/atomic replace through FILE_DELETE_CHILD inherited by directories, without granting DELETE on the write root itself. Hard-linked file descendants whose aliases all stay inside the write roots are allowed — this is what makes cargo's link_or_copy work with a narrowed ~/.cargo/registry write root instead of the broader ~/.cargo — while a hardlink that aliases a file outside the write roots is rejected with every alias path listed, so align the write roots with the locations the build actually shares. Nested symlink/reparse point descendants are unsupported and rejected. Concurrent path replacement races (TOCTOU) remain a risk.

Consequences: synthetic capability allow ACEs persist after successful execution, and a failure on a later root leaves the earlier ones in place (the process is not started and no whole-DACL rollback is attempted); these SID ACEs are inert for ordinary tokens, but administrators may need to remove them manually. Cancellation, timeout, and running-task registry teardown terminate only the top-level process, so descendants may keep running with the capability and keep writing the allowed roots; Job Object assignment with process-tree termination is a future enhancement. Windows shell execution with protected Git metadata (protect_git = true, used by delegated subagents/fixers) is unsupported and fails closed before token or ACL changes with actionable guidance in the error message; there is no .git ACL carve-out, and a role can opt out with protect_git = false in its frontmatter (see "Role frontmatter: protect_git" above), restoring a working shell for that role.

On Linux/macOS every bash call—main agent and subagents alike—is wrapped in bwrap: system directories are mounted read-only, the workspace is mounted read-write (workspace_writable = false makes it read-only), /tmp is the host's real /tmp (bound writable for main-agent and subagent Bash alike), /home is a fresh tmpfs, PID/IPC/UTS namespaces are unshared, and TIOCSTI is blocked via --new-session. Network stays available by default; network = false unshares it. When the host uses systemd-resolved, the stub resolver at /run/systemd/resolve is mounted read-only so DNS resolution via the symlinked /etc/resolv.conf works inside the sandbox. gpu = true (off by default and global-config only) additionally exposes the host GPU device nodes and the AMD ROCm sysfs subtrees described under gpu in the sandbox config; that enlarges the kernel/driver attack surface and shares GPUs — a resource with no per-command isolation — with model-generated code. The restriction constrains the spawned command, not the agent process itself. It is best-effort: bwrap is not setuid, the host network is shared by default, and environment variables of the parent process other than the stripped credential names listed above remain visible.

On Linux/Android, the workspace .git entry depends on the role: the main agent leaves it writable for repository operations, while delegated subagents/fixers bind it read-only (for a linked worktree, the .git pointer plus the caller-authorized main-worktree metadata and administrative paths, with writable aliases rejected) and normal workspace files stay writable. This does not authorize other repositories or external object stores. Background commands inherit the parent's role. The tests that pin this guard execute REAL sandboxed bash (the delegate::tests::sandbox_* cases plus resume_of_a_finished_fork_refuses_a_write_to_git), so the Linux acceptance environment must have a working bwrap: when it is missing those tests fail with installation guidance instead of passing on an assertion that never ran, and the rust CI job installs bubblewrap and runs the same capability probe (bwrap --unshare-all --ro-bind / / true) before cargo test, so a broken sandbox fails that step instead. Other platforms have no bubblewrap and skip the tests visibly, by name.

Code mode: run_rust (experimental)

[code_mode] enabled = true in the user-level config registers a main-agent-only tool that compiles and runs one model-supplied Rust source (edition 2021, std only, ≤ 128 KiB) inside a forced bubblewrap sandbox. It follows the resolved [sandbox] policy and needs a factory restart after a policy change.

Background tasks

The bash tool accepts background: true to run a command without blocking. Bash tasks 8000 and subagents share one running-task registry with no built-in concurrency limit; callers remain responsible for resource use. Background bash has the same workspace cwd, process-group handling, and per-stream 64 KiB output limit as foreground Bash, with a 30-minute timeout. Completions surface as a TUI notification while a turn is active, and the complete output is injected as a clearly labelled user message at the next model call — whether that is the next round of an active turn or, if the agent is idle, a new turn started by that delivery. F2 toggles a tasks panel listing what is running. In one-shot mode a still-running task is reported before exit; the process then best-effort terminates its process group. Uninjected background results are not persisted in sessions.

A foreground command that overruns its residence threshold and is adopted into the background is monitored exactly like an explicit background: true task — adoption does not change the in-flight task, so it is already watched: five minutes without output raises one stall Notice (runtime, silence duration, full command, current output tail) to its owning session, and new output re-arms the cadence. Monitoring follows the same rule on both paths: the task must belong to a session (owner_session), so a main-session task is not monitored.

A FinishWhenIdle session (a delegated subagent, or a one-shot CLI session) that finished its work waits indefinitely for its blocking background tasks before finalizing. Each completion is injected and acknowledged, allowing the model to continue in a follow-up turn. Detached tasks do not block finalization and may outlive the session.

The durable background-task table is a live view of the tasks this session still owns, not an execution history. Detached tasks are excluded. After a restart, leftover rows are reported as killed with the process and then cleared. Running the same session in two processes at once can cause false killed reports and overwrite task records. Task records can lag behind running work when saving fails, and a crash during cleanup can leave a finished task reported as killed on the next start.

Subagents

The delegate tool spawns a subagent with a fresh context to work on a self-contained task. Use it for subtasks whose intermediate steps (searching, reading many files, focused edits) would clutter the main context.

Each subagent runs as an independent background task with an empty history and its own isolated agent state and event log; the parent's running-task registry stays shared, so nested background bash commands remain visible and report completion to the parent. It gets the same builtins as its parent — file and bash tools plus, when configured, web search — but no MCP tools and no delegate itself, so delegation depth is capped at 1 by construction. Tool rounds are unlimited.

fork: true is the one explicit exception to that empty history. The child starts from the parent's completed-turn prefix (the in-flight turn is excluded, so put everything the child needs in task) and reads that prefix back from the parent session, so spawning a fork does not copy the parent history. It runs on the parent's current model, inheriting the parent's system prompt and MCP tool set, and the parent's goal is frozen into its request. A fork does not expose the parent's main-only tools, so its tool set matches the parent's only when the parent exposed no such tool. workspace is optional and defaults to the parent root: with that default and an identical tool set the child's request reuses the parent's provider-side prompt cache; an explicit different workspace only moves the child's file/bash tools and MCP connections there, so the prefix and cache hit are no longer guaranteed. A fork still cannot delegate further or ask the user questions. Its bash keeps the delegated-subagent .git guard even though the parent's own shell may write Git metadata, and it keeps it for the session's whole life: resuming a finished fork — including one that compacted its own history — re-installs the same guard instead of falling back to the resumed role's protect_git. That holds for both fork layouts (the current zero-copy one and the copy-based rows older builds wrote): the session's stored rows are asked, never the compaction-bounded head. Constraints: fork is mutually exclusive with role and resume, and the parent must have a completed turn (a mid-turn compaction is rejected). This is the only case where a subagent gets MCP tools.

Subagents always run in the background without blocking the main agent; there is no foreground mode. The immediate tool result includes both the background task number and subagent session ID, and its completion includes that same session ID when delivered as a background task completion (waking an idle agent). Legacy calls passing a background parameter are rejected.

A delegated child that is still running 30 minutes after it was spawned puts one Notice on the parent's event channel: subagent <label> (session <sub-id>, role <role>) has been running for 30 minutes without finishing; it may be stuck on a background task of its own. Check its transcript or cancel it from the task panel. A busy parent turn receives it at its next model-call boundary; an idle session starts a new turn from it. The threshold is 30 minutes rather than the 5-minute background-bash stall threshold because one full cargo build (10–20 minutes) is a normal first tool call for a fixer; past 30 minutes no role is doing routine work any more, and the realistic cause is a child parked on its own adopted background task — a command that never exits keeps the child from finishing and from reporting anything at all. The reminder fires exactly once (one notice is enough to send the parent looking, so unlike the bash stall warning it never repeats), and it is dropped without sending anything as soon as the child stops running — normal completion, a cancel, or the parent going away. "Still running" means the child's own runner is alive: the reminder is disarmed the moment that runner exits, before the wrapper's cleanup (joining the child's background tasks, writing the terminal task projection) begins, so a child that answered in time can never be reported as stuck just because its cleanup is slow. fork: true children are one-shot delegated tasks too and get the same reminder (with role none, since a fork runs without a role). A /btw fork is an interactive conversation rather than a one-shot task and never gets this reminder.

Resuming continues a previous subagent session in place: resume: "<session id>" loads its transcript as the starting context and appends new turns to the same session. A resume without a role argument inherits the role its spawn recorded, so a [roles] <role> edit (or a role template edit) applies to the resumed child: its model is always read from the current configuration, never from the model the session recorded, and the task panel shows the role the resume actually uses. An explicit role still wins over the recorded one. A recorded role whose template no longer exists fails the resume with "the recorded role x no longer exists; pass role: explicitly" instead of silently falling back to the default subagent model; a session that recorded no role keeps using that default. A metadata snapshot that exists but cannot be read (a damaged sidecar, no snapshot left intact) fails the resume too — it is never read as "no recorded role", which would drop a read_only role's policy and hand the child write tools. An explicit role is resolved without touching that metadata at all.

A live parent and one of its currently registered child sessions may use send_message for direct progress messages: the parent targets the child's exact session ID and a child targets only parent. The receipt means queued, not delivered. Endpoints and unconsumed queues are process-local and are not durable or recoverable after restart; only a successfully committed Notice survives replay, and replay never wakes a model turn. Messages cannot target siblings, other main sessions, or finished sessions — a finished child is no longer live; continue it with the delegate tool (resume its session id with a fresh task: the role comes from the session's recorded metadata and workspace defaults to the current workspace). The send_message error message says the same when a target is not a live child. Hard abort/restart, or a persistence/consumption failure, can discard an accepted queued body; there is no retry.

A running background subagent can be watched live in the TUI: open the tasks panel with F2, select it with Up/Down, and press Enter to attach. The attached view replays everything the subagent has done so far and then follows its stream (text, tool calls, results) with the same rendering as the main view; the footer shows the task and whether it is still running. Esc detaches back to the main view (it never cancels the main turn), and the subagent keeps running after detach. While attached, prompts can be queued and an in-flight turn can be cancelled; bash tasks have no event stream and cannot be attached.

Compaction

Use /compact in the TUI or --repl to manually summarize earlier history. The agent summarizes everything before a bounded tail of the most recent messages and appends a compaction entry (summary plus that retained tail) to the append-only session log; earlier messages stay persisted and visible in the TUI. The cut never splits a tool batch, and in a zero-copy fork the tail is clamped to the inherited boundary so parent messages are only ever summarized (see "Forking a session"). Subsequent model calls use the latest summary plus everything after it. When a configured model profile provides a context window, the agent also compacts automatically at 80% usage.

Session goals

/goal set <text> records an objective; /goal continue [N] explicitly arms N follow-up turns, and /goal pause / /goal clear stop it. Active goals never arm continuation by themselves. In the web UI the goal bar stays one compact line; click it (or focus it and press Enter / Space) to expand the whole goal — objective, the latest progress, the blocked reason, every success criterion, and the evidence collected so far — and click it again to collapse.

Session output receipts (eout1) and read_output

Long tool output is stored once and referenced by an eout1 receipt; the model pages it with read_output instead of re-reading the transcript.

History tool

history searches and reads past sessions, current session entries, and tool calls through the session store. An omitted scope means session (the current session); workspace covers every session of one workspace and global every workspace of the configured store — a run against one backend never reaches another one's data.

list/search return lightweight hits — workspace_id, session_id, seq, kind and a bounded snippet — instead of whole entries, so a page reaches the model whole rather than byte-truncated. The body comes from read, which takes the hit's workspace_id + session_id + seq and reads exactly that entry. Only an omitted workspace_id falls back: the current workspace first, then a store-wide lookup by session and that exact seq, which reports an ambiguity error (naming the workspaces) instead of silently picking one.

A page is budgeted by BYTES, not only by limit: snippets shrink first and a page that still does not fit ends early, so a page can hold fewer hits than limit and still carry next_cursor — keep paging until it is null. The cursor is a keyset position (event_time, workspace_id, session_id, seq) plus a digest of the query, never the needle text, so paging neither re-walks nor repeats a page. The budget is measured on the whole serialized response; the one case it cannot bound is a SINGLE hit whose provenance alone is that big (a pathological workspace_id), which is returned whole — a response can never be smaller than its one hit — and the provider's own head/tail bound applies.

On Greptime (and on SQLite, which folds in the same place inside its own query) list/search return LOGICAL entries: superseded physical versions of a (workspace, session, seq) are resolved onto the newest one, identical payloads at the same timestamp fold, and divergent ones are an error. That is a property of those backends' history query, not of append mode or of search in general. Even there, "no repeat, no skip" holds only within a fixed snapshot: a write that lands between two pages can still appear behind the cursor. A caller that needs a perfectly stable walk must re-read from the start.

read returns the entry body (a background completion's output, a message's text). A body over 8 KiB that is a single persisted field of the CURRENT session's entry is served head+tail with a read_output ref=… paging the rest; any other long body — another session's, or a projection of several fields — is returned whole as text with a note, because read_output refs only resolve against the session that is running.

A search is bounded by a 60-second timeout on every backend, and the error is always explicit — never an empty page. On top of that, Greptime and JSONL add an explicit candidate scan window (4096 rows): the SQL/JSONL side narrows candidates and the exact match is decided afterwards, so the window bounds that scan and "search window exhausted, narrow the query" is an error. SQLite has no candidate window: it filters exactly inside its own query (instr over the decoded projection) and then applies LIMIT, so a search there returns its page directly and bounded work is the database's business.

Web UI / headless server

e-agent --serve (alias: e-agent web) starts a headless HTTP server that serves the web UI at / and a token-authenticated /api/* surface for managing live sessions. It binds 127.0.0.1:8766 by default; --host and --port (or -p) override:

e-agent web                       # http://127.0.0.1:8766
e-agent --serve --port 9000       # http://127.0.0.1:9000

Every API route requires the server token as Authorization: Bearer <token> (or ?token=<token>, the query fallback for EventSource-style clients), except the public read-only GET /api/usage/dashboard. That GET deliberately ignores missing or invalid Authorization; it accepts no token in its browser client. The token is generated once at first start — 32 random bytes, base64url, written with mode 0600 to $XDG_STATE_HOME/e-agent/server.token (falling back to ~/.local/state/e-agent/server.token when XDG_STATE_HOME is unset) — and reused across restarts so browser clients keep working. The startup log prints the token and the token file path.

The /api surface (JSON except for the SSE endpoint):

Method Path Semantics
GET /api/sessions list sessions
POST /api/sessions create a session
GET /api/sessions/{id}/events SSE: snapshot, then live events
GET /api/sessions/{id}/history segmented history (head or older)
GET /api/sessions/{id}/summary per-turn summary cache (desktop pet)
POST /api/sessions/{id}/prompt queue a prompt; with call_id, answer the waiting question

| POST | /api/sessions/{id}/btw | fork into a persistent subagent | | GET | /api/sessions/{id}/fork-candidates | turn boundaries to fork at | | POST | /api/sessions/{id}/fork | fork at a turn boundary into a fork-… session | | POST | /api/sessions/{id}/cancel | release: preempt the in-flight turn without terminating the session (with no queued messages a WaitForInput session returns to Idle and stays usable) | | POST | /api/sessions/{id}/compact | request compaction | | GET | /api/models | switchable model profile names | | GET | /api/pet/config | live desktop pet sprite settings | | GET | /api/pet/sprite | configured local sprite-sheet bytes | | POST | /api/sessions/{id}/model | switch the session's model at runtime | | POST | /api/sessions/{id}/undo | undo the most recent file operation | | PUT | /api/sessions/{id}/title | rename a session | | PUT | /api/sessions/{id}/pin | pin a session | | PUT | /api/sessions/{id}/archive | archive a session | | DELETE | /api/sessions/{id} | cancel + remove from the registry | | GET | /api/usage/dashboard | public read-only usage JSON (SQLite/Greptime; JSONL returns 503) | | GET | /api/provider-quotas | account balance/quota cards for configured providers (authenticated) | | GET | /api/tasks | running background tasks, all sessions | | DELETE | /api/sessions/{id}/tasks/{task_id} | cancel one background task | | GET | /api/sessions/{id}/tasks/{task_id}/output | full output of a running bash task | | GET | /api/sessions/{id}/refs/status | per-link chip state + one-line detail, gh-backed, 60-second memory cache; ?cache_only=1 answers the last known observation (state + blocked + state_age_secs, plus watching: "stopped" and its reason when the watcher gave up) without ever asking gh, which is what the 2-second heartbeat reads; a stack's entry also carries layers ([{number, state, draft, title, head_ref}], bottom → top, title/head_ref absent when unread) — the sidebar's refs[] list never does | | POST | /api/sessions/{id}/refs/watch | "check now": wake the live session's PR watcher for one ordinary poll (202 woken / nothing / rate-limited, 409 when there is no watcher) | | GET | /api/refs/search?number=29 | ids of this workspace's sessions whose stored link IS PR/issue 29 (…/pull/29 or …/issues/29); supported: false on JSONL — the sidebar filter's number union |

Answering a waiting question posts {"text", "call_id"} for a one-question request, and {"answers": [{"id", "text"}, …], "call_id"} for a request that asks several: a blocking request_user_input call may ask up to 8 questions, each rendered as its own card in the web panel, and the whole set is submitted at once (an answer set that misses, repeats or invents a question id is a 400 and the question stays answerable). answers and text/prompt never appear in the same body, and answers always requires call_id. request_user_input options are suggestions — the human may always answer in their own words — while an ACP permission answer must be exactly one of the offered ids. The TUI and the --repl frontend answer a batch one question at a time (the TUI's input-box title shows (2/3), the REPL prefixes the prompt with (1/2)) and submit it only after the last answer.

Session links

A session can hold pull-request, issue, and plain links (link_ref, list_refs, unlink_ref; SQLite/Greptime backends only, and MAIN SESSION ONLY — a subagent is offered none of the three and never watches anything, because it exists to finish one delegated task and must not start turns of its own). A link is named ONE way — ref: a number (27 or #27, and no other spelling: a prefix may not declare a kind), an owner/repo/stack/N stack path, or a full URL. No input states a kind: a number is resolved against the session's git origin/repo and GitHub decides whether it is a pull request or an issue (one repository shares one number space, and only a pull request carries GitHub's pull_request field). When GitHub cannot answer — the number exists nowhere, or the lookup cannot run — the add is an error and NOTHING is stored: a guessed kind would file a row, a chip and a watch against the wrong object, so pass the full URL instead. A URL's path decides (/pull/N → pull request, /issues/N → issue, /stack/N → a stacked pull request) and every other URL is a plain link. A stack's number is a number space of its OWN — the /pulls/N page for a stack number is a 404 — so no bare number can name one: the spellings are owner/repo/stack/N and a /stack/N URL. The web editor's single input takes the same forms, and a link is removed by the exact URL list_refs returned (never by number). A GitHub PR/issue/stack link is stored as the OBJECT it denotes: the URL is canonicalized on the way in (https://github.com/Owner/Repo/pull/27#discussion → https://github.com/owner/repo/pull/27, /pulls/ → /pull/, an issue keeps /issues/, /stacks/ → /stack/), so one pull request is one row however it was typed, and adding another spelling of a linked object is an idempotent no-op that returns the existing row. Every other URL is stored exactly as given. Existing databases are normalized once on open (a fragment and a differently-cased duplicate collapse into one row, earliest position kept). In the web UI each link is a chip: the label stays the full identity (owner/repo#27), shortened to #27 when the link lives in the session's own repository — that session's origin already names it, or to EE#27 when that repository has a [ref_abbr] name — and the chip carries at most one small state dot:

[ref_abbr] — short names for the repositories you link often

[ref_abbr]
EE = "https://github.com/GreptimeTeam/greptimedb-enterprise"
gt = "https://github.com/GreptimeTeam/greptimedb"
8BD0

The key is the short name, the value a GitHub repository ROOT (https://github.com/owner/repo; the bare owner/repo and github.com/owner/repo spellings are accepted and normalized). A name is 1-16 characters of A-Z a-z 0-9 _ - — no #, / or space, because those spell owner/repo#N and a name carrying one could not be told apart from it — and one abbreviation per repository. A global [ref_abbr] and a project <workspace>/.e-agent/config.toml one merge by name, like [models]: a project name replaces the same-named global one and every other global name survives. A bad key (unusable name, two names for one repository) or a bad value (anything that is not a repository root: a /pull/27 tail, another host, a port, a query) refuses startup with the offending key named.

The alias is display and input only — the stored link is still its canonical URL, so renaming or dropping an abbreviation never rewrites a row:

  • ref accepts EE#123 (the number form in that repository; GitHub still decides pull request vs issue), EE/issues/45 and EE/stack/66. An unknown name is an error naming it — "unknown ref abbreviation" plus the name — never an owner guess: a lookup under a repository that merely happens to be called zz would link the wrong object. owner/repo/stack/N and full URLs keep their existing readings, and repo cannot be combined with a name.
  • only link_ref reads a name. unlink_ref deletes by the exact URL list_refs returned and refuses an abbreviation outright ("abbreviations are not accepted"): a name can be re-pointed (EE A → B) between the list and the delete, so expanding it would delete an object the caller never named.
  • the chip prints EE#123 (EE⧉66 for a stack), while the popover, the title, label, list_refs and unlink_ref keep the full owner/repo#123. The session's OWN repository keeps its bare #27 even when it is abbreviated (the same-repository rule wins); the sidebar row, which has no per-session origin to compare against, applies the name by repository alone. A stack's LAYER chips carry the same prefix as the stack chip (EE#63 → EE#64), because a layer is a PR of that same repository.
  • Both directions are hot-reloaded: a [ref_abbr] edit applies to the next link_ref call and the next chip/sidebar render, without a restart. The table is one live cell per session factory, so every child session (delegated, fork: true, /btw) is bound to the same one — even though the three link tools themselves stay main-session only.

The dot is an 8px pie, and it has two independent axes, both drawn at once. Each colour is one category; a wedge's size says "yes / no", never "how many", and there is no outline around the pie — its edge is the state colour itself:

Dot colour state — what the link IS
green, whole pie ready: open, merge clean, every check settled and green (or no checks)
blue, whole pie approved, but not green yet (pending checks, BEHIND, a merge state GitHub cannot compute)
blue, hollow ring open, in flight
grey, whole pie draft
purple, whole pie merged
dark red, whole pie closed without merging
grey, hollow ring the lookup was attempted and failed (unknown)
(none) never observed, or a plain link; nothing was looked up
Orange right half blocked — what stands in the way
present a merge conflict (DIRTY), a failing check, or a review requesting changes
absent nothing in the way

The two combine instead of one replacing the other — the left half of the pie is the state colour, and the right half turning orange means something stands in the way: a draft with conflicts is a grey pie whose right half is orange, an open PR whose review asks for changes is the hollow blue ring whose right half is orange, an approved PR with a failing check is a solid blue pie with the same orange half, and so on. There is no "needs you" state — state answers what the link is and blocked answers whether it wants something from you. A terminal link (merged, closed) never paints the orange half and never lists a reason, even when GitHub still reports DIRTY for it: a closed PR is not asking for anything. A chip also carries a small count badge when the pull request has unresolved review comments (3, or 3+ when the count stopped at the 500-thread cap); a link whose count was never read shows no badge — "not read" is not "none". Hovering or focusing a chip opens a real popover (a native title tooltip cannot hold links): the label and the title are the new-tab link to the PR/issue, followed by the state line state · merge · review · checks · head, the diff size +1,234 / −567 · 12 个文件 when it was read, the failing check names when a check is failing, and the unresolved-comment count. There is no separate "open" row: the title is the entry. A plain link's popover is its label, which is the link. Escape closes it; moving away closes after a short grace so the pointer can travel into it; focusing the chip and tabbing enters its links. The expanded editor row is the same clickable link. A plain link has no dot and no status.

A stack is not one chip holding a chain: it is a group of chips, one per thing you can open —

(⧉ 10811): (● 10803) → (● 10804) → (● 10691) → (● 10810)

— where each pair of parentheses is one independent chip. The stack itself is one ordinary chip in the usual place (.chat-ref-chip.stack, the neutral --base01 border) with the one dot that describes the WHOLE stack. Right behind it comes the plain text : (outside every chip), then one ordinary PR chip per layer ((● 10803), .chat-ref-chip.pr — its own dot, its own state, linked to that pull request's /pull/N), with the plain text -> between layers only. The stack's own number wears ⧉ (never # — a stack number is not a PR number) and is printed ⧉ 10811: ⧉ is a marker, not part of the number, so the chip keeps a space after it (the backend short is ⧉10811, the chip inserts the space) and shortens it exactly like #27 in the session's own repository.

Every layer is an ordinary PR link, not a stand-in drawn from the stack document. When the frontend reads a stack's layers, it links each layer it does not already hold through the very endpoint the + 链接 editor uses (POST /api/sessions/{id}/refs, one call per layer, canonical URL https://github.com/<owner>/<repo>/pull/<n>). It only does that once per missing layer: a layer already in refs is never sent twice, a layer you removed with its own × is never silently re-added by the next heartbeat (removing it means "I do not care about this layer"), and a stack that lost a layer only ever adds — it never cancels a link. So refs holds the stack plus one plain pr link per layer, and the layer chip is drawn from that very entry: data-ref-url, its own × (dropping it drops just that layer; the × on the stack drops the stack and its layers), its own /refs/status row, the ordinary PR popover and the ordinary 2-second in-place heartbeat. The layer's pull request is watched by the same PR watcher as any other link, and the layers appear in the sidebar's refs line like any other PR. A just-requested layer has no chip until it lands in refs — the next tick draws it. A layer chip is drawn in its own stack's group only, so one link is one chip on screen. Layer order is the stack document's layers order (bottom → top); nothing is re-sorted.

Each layer chip's dot comes from ITS OWN link (/refs/status row for that pull URL, the same cache and heartbeat every other PR uses), so a layer's state and the stack's line about it are two observations of two objects, not one value printed twice. The stack's OWN dot and line still come from one gh api repos/{owner}/{repo}/stacks/{N} read — pull_requests is already in layer order (bottom → top) and carries each layer's state, draft and merged_at, so the stack never fans out into a PR read per layer to describe itself. The stack's dot is decided from those layers and never guessed: all layers merged → merged; all closed without merging → closed; the stack document says open: false → closed (a real stack can end with one merged layer and one closed one); otherwise the bottom-most layer that has not landed decides, because nothing above it can merge first — draft if that layer is a draft, else open. That layer is also the one the detail row names (底层 #10803 草稿), so the dot and the line are one answer and cannot disagree: a stack whose next layer is a draft is draft even when the layers below it already merged. An unreadable layer — a state that is not a pull request token, a missing draft, a merged_at that is neither an explicit null nor an RFC 3339 timestamp — makes the whole stack unknown rather than claiming a merge (or a close) nobody saw, and an open layer carrying a merge time is a document contradicting itself, so it is unknown too. There is no ready/approved for a stack: one REST read has no checks and no review decision, and neither is invented. The one blocker a stack documents is its own word — 层已关闭, a layer that was closed without being merged, so the stack can never land as stacked. The state line reads like 草稿 · 4 层 · 4 草稿 · 底层 #10803 草稿. The stack chip's popover keeps the same rows (the title row becomes owner/repo stack #N, linked to the stack, the state line follows); the layers are their own chips beside it, not popover rows. The 2-second heartbeat updates them in place: a layer whose state changed repaints that one layer's dot (the same chip, the same dot node — an open popover and keyboard focus survive), and only a changed LINK SET (a layer just linked in, or one you removed) redraws the strip, because that changes which link is drawn where. A stack link itself is never watched and never enters the sidebar's refs line — the sidebar keeps treating it like any other non-PR/issue link, while its layers, being plain PR links, do. A stack URL that was stored as a plain link before stacks existed is repaired on the next connect (a database-wide normalization pass re-kinds exactly that one case into stack); nothing else is ever re-derived from a URL.

Statuses are read from the gh CLI, cached in memory for 60 seconds per (repo, number), and never written to the session store. They are read when a frontend opens a session's links, when a link is added (one immediate, non-blocking fetch), and when the user explicitly retries one link or refreshes all links in the header. A failed observation is unknown (muted ring); a link this process never observed has no dot at all. The dot is not a button — the chip's click still opens the link. A failed link's popover offers 重试, a never-observed one offers 查询状态, and the header's ↻ refreshes every link of the session, all without starting a model turn. A plain link has no status. The 👁 next to ↻ is a different action: it wakes the watcher (see below) for one ordinary poll now — not a chip refresh. Its feedback is the existing transient banner, and a session with no watcher (subagent, closed) answers 409 instead of pretending.

The tools (list_refs, link_ref, unlink_ref) report a status token only when the in-memory cache already holds an observation: a cache miss omits the field (no placeholder, no gh call from the tool), a failed observation is "unknown", and a successful one is the lifecycle token (open, draft, ready, approved, merged, closed). The second axis rides beside it as blocked — a list of the blocker words (["合并冲突"], ["检查失败"], ["层已关闭"], …), absent when nothing is in the way — so a caller never has to read the token to find out whether the link wants something. Stacks are listed in their own stacks array (label owner/repo⧉10811) so prs and issues keep their exact shape. A plain link never has a status field.

PR/issue watcher

While a session is live, its linked open PRs and issues are also watched independently of the web UI: one hidden task in the session's existing background registry polls every five minutes. Each independently mutable resource revalidates with its own If-None-Match (the PR document, check runs, commit statuses, reviews), while comment lists are bounded by issues/{n}/comments?since= / review-comment watermarks. An unchanged poll therefore sends only conditional reads for those REST resources — plus ONE unconditional request per pull request, the GraphQL read of GitHub's aggregate reviewDecision and of the first page of its reviewThreads (neither is exposed by a REST resource, neither answer carries a validator, and one document answers both). It produces nothing to report: a 304 on a resource and an unchanged answer to that one request are both "no change", and a change reads the nested resources it needs. A 403/429 pauses the whole watcher until X-RateLimit-Reset.

Five minutes is the default cadence, not a rule: a frontend "check now" (👁) waking the session — one POST /api/sessions/{id}/refs/watch — makes the SAME loop run its ordinary tick immediately (same staging, baselines, notice rules and cursors; only the unresolved-comment reminder's own thirty-minute period is skipped, because the human asked), through the session's existing command channel. It is never a way around a rate limit: while a 403/429 window is in force the wake issues no request and reports the reset instead.

Only transitions become a turn: checks going from all-passing (or pending) to failing, a review decision becoming changes-requested or approved, a merge, a close, and new comments/reviews. An unchanged state produces nothing — the unresolved-count reminder below is the one deliberate exception, and even that never states the same display value twice in a row: it repeats on its period, not on every read. Several changes found in one poll coalesce into one message. Merged and closed links are dropped and never polled again. The first observation of a link (including every restart) is a silent baseline: the watcher records current state and the comment watermark, so it never reports the past. Adding a link while the session is live uses the same add-time status observation as that baseline: the immediate add fetch is silent, the add itself never produces a turn, and the first transition after the add does.

The unresolved review-thread count is the ONE thing that is also repeated, because it is a number that can sit still for days: a change — 0 → N, N → M, N → 0 — is one notice, and while the count stays above zero the link states it again every thirty minutes, each link on its own clock, so the human is not their own reminder. Three shapes say it:

PR owner/repo#27 有 3 条未解决评论
PR owner/repo#27 当前无未解决评论
PR owner/repo#27 未解决评论已清零

The third claims a clearing, so it is used only when a count was READ as a positive number before; an unknown count that reads zero is the neutral first count instead. A count that ran past the first page of reviewThreads is a floor and prints 3+ (the threads are read once per poll, never paged: the notice does not cost a second request), and 3+ and 3 are two different display values, so each is stated once. A count that could not be read is never stated at all — "not read" is not 0, so a failing read cannot report a pull request as clean. The add-time baseline of a link is that same FIRST page, never the chip's total across pages: the two answer different questions and comparing them would invent a change. 👁 answers with a value that differs from the last value this link announced — 当前无未解决评论 included — instead of waiting out that half hour, and never restates that last announced value, not even after the period has run out: a press answers, it does not repeat, so an unreadable read in between cannot make an already stated count look new.

The message is delivered through the existing durable Notice projection, so the transcript renders a dim notice rather than a user bubble, while the model sees the same text as a user-shaped message:

[自动检测 · 非用户消息] PR owner/repo#27 检查失败:build, test(2 项)
discord9 · "这版先别合,测试挂了"
——本消息由 PR 监视自动生成,不是用户发言;请据此判断并采取必要行动。

There is no gate or confirmation: the notice is committed durably, arms one ordinary model turn, and the model acts under its normal rules. The watcher holds no persisted state, shares the session's lifetime (runner drop, session teardown/delete, and process exit all abort it), and never impersonates the human in the notice, a bubble, or send_message.

MCP (local servers)

e-agent can connect to local MCP servers over stdio and expose their tools to the model with a <server>_<tool> name prefix. Servers are declared in the same TOML config file as model profiles ($XDG_CONFIG_HOME/e-agent/config.toml, falling back to ~/.config/e-agent/config.toml):

[mcp.engram]
command = ["/path/to/engram", "mcp", "--tools=agent"]
enabled = true        # optional, default true
# cwd = "/other/dir"  # optional, defaults to the workspace root
# env = { KEY = "value" }

A project-level <workspace>/.e-agent/config.toml [mcp] section overlays these servers by name: a project server replaces the same-named global server, and servers only the global config defines keep their definitions. Because each entry spawns command, both the global and the project config are trusted inputs — only open workspaces you trust, since opening a repo executes the commands its .e-agent/config.toml declares. A global [mcp."<name>"] enabled = false is a kill switch a project file cannot re-enable: the merged config keeps the disabled global entry, so a same-named project server is skipped (connect_all skips disabled servers). Project MCP servers apply to the main session and to explicit fork: true delegates, which reconnect the parent's project servers in the child's own workspace (a server that fails to start is skipped, exactly as for a main session). Ordinary subagents do not connect MCP.

Servers are connected one at a time at startup; a server that fails to start is skipped with a warning and does not abort the session. Server-provided instructions (from the MCP initialize response) are prepended to the model context as a system message on every call, but are not persisted in sessions. Only tools are supported — no resources, prompts, or server-initiated notifications. MCP tools are sorted by name, so the tool array a provider sees is stable across runs and a forked child can reuse the parent's prompt cache.

Environment

  • OPENAI_API_KEY — required in environment-variable mode.
  • OPENAI_BASE_URL — API base URL, default: https://api.openai.com/v1.
  • OPENAI_MODEL — model name, default: gpt-4o-mini.
  • EXA_API_KEY — optional; a non-whitespace value enables web_search through Exa Context. [web_search] provider = "searxng" needs no environment variable: its base_url comes from the config file only. See Web tools.
  • RUST_BACKTRACE=1 — optional; appends a backtrace to ordinary anyhow error chains (and enables their full Rust verbosity). Rust panics always print a forced stack regardless of this setting.
  • RUST_LOG — optional tracing filter for operational diagnostics; defaults to e_agent=info (for example, RUST_LOG=e_agent=debug). Logs are compact, human-readable, and written to stderr without ANSI escapes.

Panic reports

A Rust panic prints its thread, location, and forced stack to stderr while omitting the panic payload. It also writes a private crash report to $XDG_STATE_HOME/e-agent/crash/latest.log, or, when XDG_STATE_HOME is unset, ~/.config/e-agent/crash/latest.log. On the next startup, e-agent reports the previous crash and renames latest.log to previous.log.

The global panic hook also observes Tokio worker and subagent task panics. Such a panic may be caught by Tokio as a JoinError, so its diagnostic and report do not by themselves mean the main TUI exited or that the application is fatal.

Panic reports are not guaranteed for SIGKILL, OOM termination, aborts, segmentation faults, or a top-level Err return; those are not ordinary Rust panics.

TOML config is optional. When present, it supplies the selected provider credential and profile values instead of OPENAI_*; see Run.

Web tools

web_search and web_fetch are registered together as soon as one web-search source is usable: EXA_API_KEY, [web_search] provider = "searxng" plus a base_url, or provider = "deepseek" plus a credential. With no usable source neither tool exists, and a blank credential registers nothing.

web_fetch is a single-URL fetch performed by this process: it GETs the URL over the network this process already has, follows at most 5 redirects, and accepts text/html, application/xhtml+xml, text/plain and text/markdown bodies up to 2 MiB. Bytes are decoded with the Content-Type charset, else a <meta charset> sniff, else UTF-8 (lossy, so GBK/Big5 pages are readable). HTML goes through Mozilla Readability (dom_smoothie) and comes back as the article title plus Markdown; a page with no readable article is an error, not a dump of tags and navigation. text/plain and text/markdown are returned as they are. It never follows links found in the page, so it is not a crawler. Because it runs in this process it reaches whatever the process reaches — the same network bash has, not only public hosts (see Safety boundaries).

[web_search] fetch_provider selects the fetch transport:

[web_search]
provider = "searxng"
base_url = "http://127.0.0.1:8088"
fetch_provider = "deepseek"      # optional: "local" (default) or "deepseek"
api_key_env = "DEEPSEEK_API_KEY" # allowed here only because the fetch needs it

"local" (the default when the field is absent) uses this process. fetch_provider = "deepseek" keeps the remote tools/fetch — DeepSeek's servers do the fetching, so a page they cannot reach fails — and requires a credential. The two choices are independent: a SearXNG search can pair with a DeepSeek fetch. provider still rejects a base_url for "deepseek", and api_key_file / api_key_env are rejected for a SearXNG search unless fetch_provider = "deepseek" needs them.

Image input (multimodal)

read_image (tool) and the REPL /image <path> command attach png/jpeg/webp/gif images up to 10 MiB; bytes are stored once in a content-addressed cache under $XDG_STATE_HOME/e-agent/images/. Sessions persist only the reference, never base64, and the wire re-reads the file when sending.

Profiles are vision-capable by default, so image parts in a request — including references already stored in the session history — go to the provider. Set vision = false for a text-only model: image parts are then stripped from every outgoing request (the affected message text gains a short note that the images were skipped), while the session history keeps the references, so switching back to a vision model sends them again. An explicit / 69ED image <path> on a non-vision model is refused before anything is committed: the rejection is reported as an error and the session stays alive instead of failing. Leaving the default on for a text-only model sends the images anyway. When the provider answers with a recognized image rejection the request is retried once with the images omitted, and the turn continues normally on that reply; only when the retry fails too does the turn end with image-free retry failed. generate_image (main session only, ChatGPT login) writes a PNG.

Upgrading from a config that omits vision. Omitting vision used to mean "images are refused"; it now means "vision is on". Every profile that omits vision — including one written for a text-only model — starts transmitting images: newly attached ones, and the ones already recorded in that session's history. To keep the old behaviour, set vision = false on each such profile ([models."<provider>/<name>"] in config.toml):

[models."deepseek/deepseek-chat"]
vision = false                     # text-only: keep images off the wire

SQLite session backend

The default backend stores sessions in <workspace>/.e-agent/sessions.db (override with [session] path, or select backend = "jsonl").

GreptimeDB session backend (experimental)

[session] backend = "greptime" and conn = "host=… port=… dbname=…" store sessions in GreptimeDB instead; the server must be running before e-agent starts.

Non-goals

  • No daemon, JSONL protocol, subagent framework, permission framework, plugin host, generic provider/auth framework, parallel tool executor, task scheduler, priority system, or concurrency pool.
  • No provider/model catalog fetching, config generation, metadata caching, or context-window inference; TOML profiles are static local settings.
  • AGENTS.md loading is workspace-root only: no parent or nested discovery.
  • Subagents are runtime tasks, not processes: no agent-to-agent messaging beyond live parent/child send_message, no delegation past one level.
  • A long-running delegate gets one parent Notice after 30 minutes and nothing more: it never cancels, pauses, or restarts the child, never repeats or escalates, has no per-role threshold, and never fires for a /btw fork (an interactive conversation is not a one-shot task).
  • Cancellation is a release, not a termination.
  • No idle-runner GC, no shell-command classifier, and no forced turn ending for background waits.
  • MCP is local stdio servers only; no remote HTTP/SSE, OAuth, resources, prompts, or server restart.
  • Session links have no webhooks, no dedicated scheduler or process, and no persisted watcher state. The watcher is one task in the session's existing background registry, polls only open PR/issue links every five minutes with ETag/rate-limit handling, and drops merged/closed links. A chip's state stays a 60-second in-memory gh read (unknown whenever that read fails), with no status for plain links.
  • No stack watcher, no GraphQL stack/stackEntry, no per-layer read to DESCRIBE a stack, no sidebar expansion of layers: a stack's one observation is one REST read taken on demand by the chip. refs[] (the sidebar's list) does not carry layers — the layers it does carry are ordinary pull-request links the frontend created for them, one each.
  • No cross-forge link canonicalization: only GitHub PR/issue/stack object URLs are folded into one row. A GitLab or plain URL keeps the text it was given, so two spellings of it remain two links.
  • The web server has no multi-user model: one token, one workspace per process.
  • Windows support is narrower than Linux (see the sandbox notes above).

About

A Rust coding agent with async subagents, goal-driven continuous execution, and terminal and web UIs.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0