Core Concepts
Branches
A branch is an isolated workspace for changes: Key properties:- Each task has a default branch (usually “main”)
- Branches are isolated—changes don’t affect other branches
- Create branches for experimentation without risk
Commits
A commit is an immutable snapshot of the entire task state: Key properties:- Commits are immutable—once created, they never change
- A commit captures ALL entities in the task at that moment
- Use commit IDs for reproducibility
Working State
Working state represents uncommitted changes on a branch: Key properties:- Working state is mutable
- Only exists per branch
- Gets cleared when you commit
Access Patterns
Branch Access
Fetching by branch returns the latest state (including uncommitted changes):- Start with the branch’s head commit
- Overlay any working state modifications
- Apply any deletions
- Return the merged “current state”
Commit Access
Fetching by commit returns an immutable snapshot:- The exact prompt state when that commit was created
- Guaranteed to never change
- Cached indefinitely by the SDK
Branch Head Access
To get the latest committed state (without working changes):- The most recent committed state
- No work-in-progress changes
- Still immutable
Resolution Logic
When you fetch by branch, here’s what happens: This resolution happens server-side. The SDK receives the resolved state.Production Deployment Patterns
Pattern 1: Pin to Commit
The safest approach—pin production to a specific commit:- Completely immutable
- Perfect reproducibility
- Safe from accidental changes
- Manual updates required
- Need to track commit IDs
Pattern 2: Latest Commit on Branch
Use the branch head, but only committed state:- Automatically gets new commits
- No work-in-progress changes
- Can use a “production” branch for controlled releases
- Any commit to the branch goes live
- Need branch discipline
Pattern 3: Branch Access (Development Only)
For development and testing:- Always latest, including uncommitted
- Great for rapid iteration
- Can change unexpectedly
- Not suitable for production
Caching Behavior
The SDK caches based on access pattern:| Access | Cached | Reason |
|---|---|---|
commit_id="..." | Yes | Commits are immutable |
branch_name="..." | No | Branches change |
Branch Response Fields
When fetching a branch head:Entity Version Context
Fetched entities include version context:- Knowing which version you’re working with
- Including version info in telemetry
- Debugging version-related issues
Immutability Guarantees
What’s Immutable
- Commits: Once created, never change
- Version records: The state captured in a commit
- Content records: Message and property content is content-addressed
What’s Mutable
- Working state: Changes until committed
- Branch pointers: Head moves with new commits
- Deletions: Tracked per-branch
Best Practices
Use commit IDs in production
Use commit IDs in production
Always pin production deployments to specific commit IDs for reproducibility.
Create feature branches for experiments
Create feature branches for experiments
Don’t experiment on main. Create branches to test changes safely.
Commit early and often
Commit early and often
Commits are cheap and create restore points.
Use branch names in development
Use branch names in development
During development, use branch access for rapid iteration.
Consider a production branch
Consider a production branch
Use a dedicated “production” branch that only gets stable commits.