-
Notifications
You must be signed in to change notification settings - Fork 186
Better agent agent instructions #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+76
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ded784c
add a new requirement/checklist file any new agent integration can be…
Soph 54054eb
making clearer what we want to store
Soph c976ea5
use actual syntax
Soph 39156ef
more refinement
Soph b724780
Merge branch 'main' into soph/better-agent-agent-instructions
Soph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Agent Integration Checklist | ||
Soph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| This document provides requirements and a checklist for integrating new AI coding agents with Entire. Use this when implementing support for a new agent (e.g., Claude Code, Gemini CLI, OpenCode). | ||
Soph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Core Principle: Full Transcript Storage | ||
|
|
||
| Entire stores the **complete session transcript** at every checkpoint, not incremental diffs. This enables: | ||
|
|
||
| - Simple rewind: restore the full transcript, agent resumes from that state | ||
| - No dependency on previous checkpoints being intact | ||
| - Consistent behavior across all checkpoint types (committed, uncommitted) | ||
|
|
||
| **Each checkpoint must contain the full session history up to that point.** | ||
|
|
||
| ## Core Principle: Native Format Preservation | ||
|
|
||
| Store transcripts in the **agent's native format**. Any transformation or normalization should only be done to support CLI features (rewind, resume, summarization, file extraction), not for backend or web UI consumption. | ||
|
|
||
| **Why:** | ||
| - The backend/web UI should handle format differences, not the CLI | ||
| - Transforming for downstream consumers couples the CLI to their requirements | ||
| - Native formats ensure compatibility with agent's own import/export tools | ||
| - Reduces risk of data loss from lossy transformations | ||
| - Format changes that break the UI can be fixed with a backend deploy; CLI changes require a full release cycle and user adoption | ||
|
|
||
| **Do:** | ||
| - Store the raw transcript as the agent produces it | ||
| - Parse the native format when CLI features need specific data (e.g., extract file paths for `entire status`) | ||
| - Let the backend normalize formats for display | ||
|
|
||
| **Don't:** | ||
| - Create a "universal transcript format" in the CLI | ||
| - Transform logs to match what the web UI expects | ||
| - Strip or restructure data to simplify backend processing | ||
| - Create intermediate formats (e.g., converting JSON to JSONL for "easier parsing") | ||
| - Reconstruct transcripts from events when a canonical export exists | ||
|
|
||
| ## Integration Checklist | ||
|
|
||
| ### Transcript Capture | ||
|
|
||
| - [ ] **Full transcript on every turn**: At turn-end, capture the complete session transcript, not just events since the last checkpoint | ||
| - [ ] **Resumed session handling**: When a user resumes an existing session, the transcript must include all historical messages, not just new ones since the plugin/hook loaded | ||
| - [ ] **Use agent's canonical export**: Prefer the agent's native export command (e.g., `opencode export`, reading Claude's JSONL file) over manually reconstructing from events | ||
| - [ ] **No custom formats**: Store the agent's native format directly in `NativeData` - do not convert between formats (e.g., JSON to JSONL) or create intermediate representations | ||
| - [ ] **Graceful degradation**: If the canonical source is unavailable (e.g., agent shutting down), fall back to best-effort capture with clear documentation of limitations | ||
|
|
||
| ### Session Storage Abstraction | ||
|
|
||
| - [ ] **`WriteSession` implementation**: Agent must implement `WriteSession(AgentSession)` to restore sessions | ||
| - [ ] **File-based agents** (Claude, Gemini): Write `NativeData` to `SessionRef` path | ||
| - [ ] **Database-backed agents**: Write `NativeData` to file, then import into native storage (the native format should be what the agent's import command expects) | ||
| - [ ] **Single format per agent**: Store only the agent's native format in `NativeData` - no separate fields for different representations of the same data | ||
|
|
||
| ### Hook Events | ||
|
|
||
| Map agent-native hooks to these `EventType` constants (see `agent/event.go`): | ||
|
|
||
| - [ ] **TurnStart**: Fire when user submits a prompt (for pre-prompt state capture) | ||
| - [ ] **TurnEnd**: Fire when agent finishes responding (for checkpoint creation) | ||
| - [ ] **SessionStart**: Fire when a new session begins | ||
| - [ ] **SessionEnd**: Fire when session is explicitly ended (optional but recommended) | ||
|
|
||
| ### Rewind/Resume Support | ||
|
|
||
| - [ ] **Rewind restores full state**: After rewind, agent can continue from that point with full context | ||
| - [ ] **Resume command**: `FormatResumeCommand()` returns the CLI command to resume a session | ||
| - [ ] **Session ID preservation**: Restored sessions maintain original session ID where possible | ||
|
|
||
| ### Testing | ||
|
|
||
| - [ ] **New session**: Create session, multiple turns, verify full transcript at each checkpoint | ||
| - [ ] **Resumed session**: Resume existing session, add turns, verify checkpoint includes historical messages | ||
| - [ ] **Rewind**: Rewind to earlier checkpoint, verify agent can continue from that state | ||
| - [ ] **Agent shutdown**: Verify graceful handling if agent exits during checkpoint | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.