Overview
GLYPH patches enable efficient incremental updates to structured state. Instead of sending the entire state document after each change, send only the operations that transform one state to another.Why Patches?
Token Efficiency
Send O(1) operations instead of O(n) full state
Base Hash Verification
Cryptographic proof you’re updating the correct version
Optimistic Concurrency
Detect and reject conflicting updates
Audit Trail
Log operations for debugging and replay
Patch Operations
GLYPH supports four core patch operations:| Operator | Name | Purpose | Example |
|---|---|---|---|
= | Set | Replace a value | = score 95 |
+ | Append | Add to list/map | + items {id=3 name=widget} |
~ | Increment | Add to number | ~ count 1 |
- | Delete | Remove key/index | - items[0] |
Set Operation (=)
Replace a field value completely.
Append Operation (+)
Add an element to a list or a key-value pair to a map.
Increment Operation (~)
Add a numeric value to an existing number (supports negative increments).
Delete Operation (-)
Remove a key from a map or an index from a list.
Base Hash Verification
Patches include a base fingerprint - the first 16 characters of the SHA-256 hash of the canonical form of the base state. This enables:- Optimistic concurrency: Reject patches applied to stale state
- Streaming validation: Verify state consistency without full doc transfer
- Debugging: Trace state divergence in distributed systems
Patch Format with Base
@base= attribute contains the first 16 hex characters of sha256(canonicalize(baseState)).
Creating Patches with Base
Applying Patches with Base Verification
Concurrent Safety
Base hash verification prevents the “lost update” problem in distributed systems.The Problem
The Solution
Example: Optimistic Concurrency
Performance Benefits
Token Savings
| Operation | Full State | Patch | Savings |
|---|---|---|---|
| Increment counter | ~120 tokens | ~8 tokens | 93% |
| Append to list | ~200 tokens | ~15 tokens | 92% |
| Update 1 of 10 fields | ~180 tokens | ~12 tokens | 93% |
| Update 3 of 10 fields | ~180 tokens | ~35 tokens | 80% |
When to Use Patches
High-Frequency Updates
High-Frequency Updates
For state that changes frequently (counters, progress, live metrics).Example: Agent updating turn count, token usage, or task completion percentage.
Large State Documents
Large State Documents
When the full state is large but updates are small.Example: 10KB agent memory, updating a single field.
Distributed Agents
Distributed Agents
When multiple agents may update the same state concurrently.Example: Multi-agent planning with shared task queue.
Append-Only Logs
Append-Only Logs
For streaming logs, events, or observation history.Example: ReAct loop appending tool results to observations.
Next Steps
Fingerprinting
Deep dive into SHA-256 state hashing
GS1 Streaming
Learn about frame-based patch delivery
Agent Patterns
See patches in multi-agent coordination
API Reference
Explore patch APIs in all languages