Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-cli/README.md # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-cli / README.md` 46 lines ยท 5929 bytes Raw Blame History Rendered 1 # aien-cli 2 3 The `aien-cli` binary is AIEN's command line and the chat loop that Allen runs in on a host. 4 5 ## Sessions: record first, then act 6 7 Every chat session keeps a journal in the sessions folder (`basecamp/sessions/.journal.jsonl` under the home folder). Each message and each tool request is written to the journal and flushed to disk before the loop acts on it. This is the chat-loop form of the Aienux continuity rule: advance the record, then act (sovereign-core #665). 8 9 - **Continue a session:** `aien-cli --resume `. The id is printed when a session starts. 10 - **After a crash:** if the process stopped after a tool request was recorded but before its result was, the resumed session runs read-only requests (view, list, search, and the `list_directory` alias of list) again. For anything else it tells Allen that it is not known whether the request happened, and it never runs that request a second time. 11 - **Autonomous goals:** `aien-cli goal auto` uses the same journal. Each tool request is on disk before the tool runs. If that write fails, the goal stops. 12 - **Damage:** a journal damaged anywhere except its last line is refused. A last line cut off mid-write is dropped. 13 - **Failed model calls:** each kind of failure gets one recovery per turn: one retry after a network error, one wait after a rate limit, and one compaction when the conversation is too long. A second failure of the same kind ends the turn with a named reason, so recovery cannot loop. 14 - **Cut-off tool calls:** a reply cut off inside a tool call is never run. It is asked again once with a higher output limit. 15 16 The plain `basecamp/sessions/.json` file is still written at the end of each turn for readers that expect it. 17 18 ## Long conversations: the operator's words are kept 19 20 When a conversation gets too long for the model, older material is folded into a short recap so the session can go on. The operator's own messages are never folded or summarized: every one stays word for word, in order, for the whole session (sovereign-core #664). Only Allen's own material is folded: his replies, tool calls, tool output and earlier recaps. The recap sits after the operator messages it follows, and a short line in it marks where each operator message came. 21 22 - **One recap:** only the newest recap is kept. When it grows past 2,000 tokens, its oldest lines are dropped. 23 - **Nothing is lost:** every folded message is kept, byte for byte, in the session's compaction records, and the records rebuild the whole original conversation. 24 - **Recorded at once:** each compaction is written to the session journal as soon as it happens, so a resumed session loads the recap or the messages it replaced, never both. If that write fails, the turn stops. Resume then loads the history from before the compaction, which was already on disk. 25 - **Per-turn folding (opt-in):** `AIEN_MICRO_COMPACT=1` folds one exchange (Allen's part of one turn) after every turn, so the cost of each pass stays small. It is off by default because every pass changes the start of the prompt the model sees. A resumed session continues after the last recap and never folds an exchange twice. 26 - **The trade-off:** because the operator's messages are never folded, very long operator messages stay in the conversation. When that alone is over the limit, the loop says so instead of cutting them. 27 28 ## Tools: side by side when safe, large output kept aside 29 30 When Allen asks for several tools in one reply, the loop plans them before running them (sovereign-core #666): 31 32 - **Reads run together:** viewing, listing and searching run side by side, up to eight at once, even on the same file. 33 - **Writes are kept apart:** a write never runs at the same time as another call on the same path or a folder that holds it. 34 - **Some tools always run alone:** shell commands, tools the planner does not know, and any call that would ask the operator for approval run alone, so two approval questions never share the screen. 35 - **Order is kept:** two calls that touch the same path run in the order Allen asked for them, and results come back in that order however they finish. Every request of a step is recorded in the journal before any of them runs. 36 - **Large output is saved to a file:** a result bigger than its share of the model's window (15 percent per result, 30 percent per reply, at least 8,000 and 16,000 characters, at most 100,000 and 200,000) is written whole to `basecamp/sessions/-spill/`. Allen gets the start and the end of it (40 and 60 percent of 1,500 characters) and the file's path, so he can read the rest a page at a time instead of running the tool again. File reads are never saved aside this way, so a saved file can always be read back. 37 38 The code is in `src/turn_journal.rs` (the journal), `src/turn_recovery.rs` (failure classes), `src/compaction.rs` (folding), and `src/tool_plan.rs`, `src/tool_batch.rs` and `src/tool_spill.rs` (tool batches). The mechanisms follow Hermes Agent (Nous Research, MIT licence, commit `5480918`). It was re-implemented from reading; no code was copied. 39 40 ### Not covered yet 41 42 - The recap is built by rule (the first line of each message), not by a language model. A model-written summary, with its own failure pacing (skip an exchange after three failures, wait 60 s, then 300 s, then 900 s), is the next part of #664. 43 - Token counts are still estimated locally. Using the counts the model server reports (#664) is not built yet. 44 - `aien-cli goal auto` does not use the interactive loop's one-shot model-call recovery, and it still runs tools one at a time (no tool batches). 45 - Tool batches have no time limit yet: a tool that hangs holds its step. Paths are compared by spelling, so a symlink that gives one file two names is not detected. 46 - Trying another credential or provider before a fallback model (part of #665) is not built: the loop has one model seat and no fallback chain.