Repository navigation
Description
Summary
In issue #200, the agent (egg) was asked to "put together an analysis doc for this and add it to the issue" but instead immediately implemented a full solution and opened PR #201. This bypassed the expected planning/review phase.
What Happened
-
Issue restrict updates to certain lines or files #200 was opened with the request: "Let's figure out a way to set up protected files or lines that the agent can't update. @james-in-a-box put together an analysis doc for this and add it to the issue"
-
Expected behavior: Write an analysis document exploring options, post it to the issue as a comment, and wait for human review before proceeding to implementation.
-
Actual behavior: The agent immediately implemented the full solution (gateway-level file protection with 39 tests) and opened PR Add protected files to prevent agent from modifying critical configs #201.
Root Cause Analysis
The agent misinterpreted "put together an analysis doc for this and add it to the issue" as part of a broader implementation task. Contributing factors:
-
Ambiguous task framing: The request mentioned both the problem ("figure out a way to set up protected files") and a documentation task ("put together an analysis doc"). The agent optimized for solving the complete problem rather than stopping at the analysis phase.
-
No infrastructure-enforced planning phase: CLAUDE.md describes a workflow (Gather Context → Plan → Implement → Test → Commit & PR), but nothing in the gateway sidecar enforces stopping at the planning phase.
-
Agent bias toward completion: LLM agents tend to complete tasks fully rather than stopping at intermediate checkpoints. Without explicit constraints, the agent proceeded through the entire workflow.
Proposed Solutions
Option 1: Gateway-enforced "plan mode"
Extend the gateway sidecar to enforce a planning phase for new issues:
- During plan mode: Only allow
gh issue commentandgh issue edit. Blockgit pushandgh pr create. - After approval: Human marks the issue with a label (e.g.,
plan-approved) or comments with a trigger phrase to unlock implementation operations. - Implementation: Add a task state machine to the gateway that tracks issue→plan→approval→implementation flow.
Pros: Infrastructure enforcement (can't be bypassed by agent instructions)
Cons: Adds complexity to gateway; may slow down simple tasks
Option 2: Separate workflows for planning vs implementation
Create two distinct agent invocation modes:
egg plan <issue-number>: Agent can only read code and post comments/analysis. All write operations blocked.egg implement <issue-number>: Full capabilities, but only available after human approval in the issue.
Pros: Clear separation of concerns; easy to understand
Cons: Requires changes to how egg is invoked
Option 3: Checkpoint-based workflow with circuit breaker
Build on issue #133 (Structurally Enforced Agent Checkpoints):
- Define mandatory checkpoints:
analysis_posted,plan_approved,implementation_complete, etc. - Gateway blocks operations that don't match the current checkpoint state.
- Human must explicitly advance the checkpoint after reviewing each phase.
Pros: Flexible; aligns with existing checkpoint work
Cons: More complex implementation; may need UI for checkpoint management
Option 4: Prompt-level restrictions (not recommended)
Add stronger CLAUDE.md instructions like "NEVER start implementation without posting a plan first."
Pros: Easy to implement
Cons: Not enforceable; agent can ignore instructions (see agent-mode-design.md: "Prompt-level instructions aren't security controls")
Recommendation
Option 1 (Gateway-enforced plan mode) is most aligned with egg's design philosophy:
"The sandbox is the constraint. If a task needs constraints beyond what the sandbox enforces, that's a signal to improve the sandbox—not to add prompt-level restrictions."
This would add a new enforcement layer to the gateway that tracks issue lifecycle and blocks operations that violate the expected workflow.
Related Issues
- Issue restrict updates to certain lines or files #200 — Original issue where this incident occurred
- Issue Implement structurally enforced agent checkpoints and verification gates #133 — Structurally Enforced Agent Checkpoints (related architecture)
- PR Add protected files to prevent agent from modifying critical configs #201 — The premature implementation that should have been a plan first
Questions for Discussion
- Should plan mode be the default for all issues, or opt-in via a label?
- How should the transition from plan to implementation be triggered?
- Should this apply to all repositories or be configurable per-repo?
— Authored by egg
Activity
Integrate issue #202 context into SDLC pipeline spec
Remove motivation section regarding #202 incident
Implement Phase 2: Phase-based operation restrictions
Implement Phase 2: Phase-based operation restrictions (#243)