Feature · 2026-05-24

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.

Diagram showing Codex and Claude capturing and recalling shared versioned context through refs/h5i
h5i keeps agent context in Git-native sidecar refs. Agents capture observations, decisions, actions, memory, and claims into the shared record, then recall the relevant slice before the next edit.

What goes into the DAG

h5i's context entries use a small vocabulary that maps cleanly to agent work:

EntryMeaningTypical source
OBSERVEWhat the agent inspected.File reads, searches, listings.
THINKA design choice, hypothesis, or rejected alternative.Agent reasoning or explicit trace.
ACTWhat changed.Patches, writes, generated files.
NOTEWhat future sessions should not miss.TODOs, limitations, risks.
MERGEReasoning 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

context
$ 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.

branch reasoning
$ 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.

The core idea: code review should not be the first time the team sees agent reasoning. The reasoning should exist throughout the work, versioned beside the code, then rendered into whatever surface the moment needs: terminal prelude, local dashboard, handoff briefing, compliance report, or PR comment.

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.