Skip to main content

Module env

Module env 

Source
Expand description

Session-start environment snapshot (C1 in CC’s taxonomy).

Captures git branch / HEAD / working-tree status once at session start (or on ChangeDir), memoized by ownership: the struct lives on AgentLoop, is constructed in new(), and renders into build_system_prompt as a dedicated section.

§Why snapshot, not live

Git status changes every turn (every tool call shifts working tree state). If we re-read each turn, the system-prompt prefix changes every turn → prompt cache breaks → every turn re-bills full prefix. CC observed this tradeoff and chose snapshot-at-session-start with an explicit disclaimer in prompt text, so the model doesn’t mistake stale info for live state. We follow that pattern.

§Graceful degradation

Non-git directories, no git binary on PATH, detached HEAD, permission errors — all surface as git: None and the prompt section is simply omitted. No panics, no half-rendered sections.

Structs§

EnvSnapshot
Session-start environment snapshot.
GitSnapshot
Git repository state at the moment of capture.