Context DAG: Version-Controlled Reasoning for AI Agents
Code has Git. Agent reasoning usually has a disappearing chat window. h5i gives Claude Code, Codex, and teammates a shared context graph that can be restored, searched, branched, merged, and attached to commits.
Most AI coding sessions lose their most valuable artifact: the reasoning. The final diff survives, but the path to it does not. Which files did the agent read? Which assumption did it reject? What was left as a TODO? Why did it choose one design over another? Those answers live in the session transcript until the next session forgets them.
h5i treats that reasoning as versionable project state. It records a context DAG under
refs/h5i/context, separate from your working tree but shareable through Git.
The next agent does not have to re-discover the project. It can recall the branch goal,
milestones, decisions, open risks, and file-specific prior reasoning before editing.
What goes into the DAG
h5i's context entries use a small vocabulary that maps cleanly to agent work:
| Entry | Meaning | Typical source |
|---|---|---|
OBSERVE | What the agent inspected. | File reads, searches, listings. |
THINK | A design choice, hypothesis, or rejected alternative. | Agent reasoning or explicit trace. |
ACT | What changed. | Patches, writes, generated files. |
NOTE | What future sessions should not miss. | TODOs, limitations, risks. |
MERGE | Reasoning from another context branch joined back. | Context branch merge. |
This is intentionally simpler than a full transcript. h5i is not trying to preserve every token. It preserves the shape of the work: what was known, what was decided, what changed, and what still matters.
Daily workflow
$ h5i recall context init --goal "ship OAuth login safely" $ h5i recall context relevant src/auth.rs $ h5i recall context trace --kind THINK \ "Redis sessions over in-process map because restarts must not log users out" $ h5i codex sync $ h5i codex finish --summary "implemented refresh-token storage"
Claude Code can automate much of this through h5i hook setup. Codex uses
explicit h5i codex prelude, sync, and finish commands.
Both end up writing to the same shared context workspace.
Branching reasoning, not just code
Agent work often includes experiments: try a lock-free design, compare two caching strategies, inspect whether a bug is in the parser or the caller. Those investigations are valuable even when you abandon them. h5i lets you branch context to isolate the experiment, then merge the useful conclusion back.
$ h5i recall context branch experiment/cache-layer \ --purpose "compare Redis cache against local LRU" # inspect, test, decide $ h5i recall context checkout main $ h5i recall context merge experiment/cache-layer
Why a DAG beats a flat memory file
A flat memory file is easy to append and hard to trust. It has no ancestry, no branch boundary, no commit linkage, and no clear difference between durable knowledge and scratch notes. A DAG gives context a structure close to the work itself.
What to read next
Use the workflow guide for day-to-day commands, or read how h5i renders the same context into a PR body when a branch is ready for review.