-
Notifications
You must be signed in to change notification settings - Fork 12
Add agent commands for AI-assisted task planning and execution #10
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
Conversation
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
Implements the RALPH (Run Agent Loop with Prompts Headlessly) workflow: - --claude (default), --opencode, --runner flags for different runners - --model flag to specify model - --once flag to run single task - --dry-run flag to preview without executing - --delay and --max-tasks safety controls - Failure tracking: skips tasks after 3 consecutive failures - Added --json support to ready command for programmatic access Also updates start.sh to be a generic RALPH runner script with: - Auto-detection of zagi binary - --import flag to import tasks from plan.md - Same flags as git tasks run 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Add new `zagi agent` command for RALPH loop execution - Remove `tasks run` subcommand (replaced by `zagi agent`) - Remove `--after` dependency syntax from tasks (simplify model) - Remove `ready` command (no longer needed without dependencies) - Support --executor flag for claudecode/opencode/custom commands - Support ZAGI_AGENT env var as default executor - Add logging to agent.log file - Add --once, --dry-run, --delay, --max-tasks safety options 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Rename 'claudecode' to 'claude' for consistency - Remove --executor flag, use ZAGI_AGENT env var only - Add ZAGI_AGENT_CMD for custom command override - Fix segfault: dupe task.id key before storing in hashmap - Remove default model - use executor defaults (claude -p, opencode run)
- Implement `zagi agent plan` for starting planning sessions - Add planning prompt with detailed instructions for task creation - Support ZAGI_AGENT_CMD for custom executor commands - Update tests to remove obsolete --after and ready references - Create friction.md documenting known issues: - ZAGI_AGENT validation missing - Relative path issues in agent - Memory leaks in tasks.zig - Add tasks 011-014 for friction fixes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Move deinit() call after print in runDelete to avoid printing freed memory - Update non-git directory test to accept both "error" and "fatal" messages 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Add escapeJsonString() helper for proper JSON output - Escape quotes, backslashes, newlines in task content for --json - Update start.sh to use tasks list --json (removed 'ready' command) - Use python3 for reliable JSON parsing of first pending task 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Use --output-format stream-json for real-time observability - Add --dangerously-skip-permissions by default for headless runs - Support CC_CMD env var to override claude command - Log per-task JSON to logs/<task-id>.json 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ipts) Shell aliases like 'cc' aren't available in scripts, so use the full 'claude --dangerously-skip-permissions' command directly. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Validates ZAGI_AGENT against known executors ('claude', 'opencode').
Invalid values like '1' now show clear error with valid options.
ZAGI_AGENT_CMD bypasses validation for custom executors.
Agents now read CONTEXT.md first to understand the overall mission, current focus, and work streams before tackling their specific task. Includes link to RALPH methodology. CONTEXT.md is ephemeral - lives for PR lifetime, deleted before merge.
Document the key concepts in the agent module: - planning_prompt_template: explains its purpose for creating self-contained, verifiable tasks during interactive planning - RALPH loop algorithm: ASCII diagram showing the execution flow with failure handling, safety limits, and exit conditions - consecutive_failures tracking: explains why we track consecutive (not total) failures and the memory management for duplicated keys
Test suite covers: - RALPH loop behavior (task execution, --once, --max-tasks) - Consecutive failure counting (increment on failure, reset on success) - Max failures exit condition (skip after 3 failures, exit when all fail) - Dry-run mode output verification - Task completion integration (marks tasks done) - Error handling (invalid ZAGI_AGENT, ZAGI_AGENT_CMD bypass)
- Reduce createFixtureRepo commit count from 100 to 20 - Switch 6 test files to use lightweight createTestRepo (1 commit) - Tests now create their own specific fixtures as needed - Result: ~74-93% faster test execution (411s -> 30s wall-clock)
Add --parallel flag to agent run command for concurrent task execution. When parallel > 1, tasks run simultaneously with streaming JSON output to individual log files (logs/<task-id>.json). Features: - --parallel <n> flag to run n tasks concurrently - Streaming JSON output via --output-format stream-json for Claude - Per-task log files for real-time visibility - Proper tracking of running tasks and completion handling - Maintains sequential mode (parallel=1) as default The parallel execution uses shell redirection to stream output directly to log files, enabling real-time monitoring of agent progress. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add two new unit tests to verify appendToTask correctly handles content containing newlines: - Test appending multi-line content to single-line original - Test when both original and addition have embedded newlines The function preserves newlines in the output; escaping for storage happens at the serialization layer via escapeContentForStorage. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
- Change 'Goal:' to 'Initial context:' (matches actual output) - Change 'PROJECT GOAL:' to 'INITIAL CONTEXT:' (matches prompt template) - Update prompt section checks (PHASE 1/4, RULES) - Fix executor expectations (claude not claude -p for interactive) - Update edit test for append-only agent behavior - Clear ZAGI_AGENT_CMD in test helper to isolate tests - Use 'claude' instead of deprecated 'claude-code'
64055a5 to
7a14484
Compare
The planning session runs interactively with the default executor model. Model selection is only available for agent run. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Model selection is handled by the executor itself. This simplifies the agent interface - users configure their preferred model in the executor's own config (e.g., claude settings). Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Log files now go to /tmp/zagi/<repo>/<hash>.log instead of agent.log - Simplified completion promise to just "TASK_DONE" - Task only completes if agent outputs TASK_DONE marker - Capture and display agent output after completion Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Require both start and end markers of completion promise - Add knowledge persistence section for AGENTS.md updates - Simplified completion promise bullet points Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ands - When ZAGI_AGENT_CMD is set with ZAGI_AGENT, mode flags are auto-added (-p for claude, run for opencode) - Add docs/setup.md with full executor configuration documentation - Add Zig tests for buildExecutorArgs covering all scenarios - Update AGENTS.md to reference new setup docs
- Split --prompts to only show prompts (200 char truncation) - Add --agent flag to show agent name only - Add --session flag to show session transcript - Add --session-offset=N and --session-limit=N for pagination - Shows byte range and suggests next offset when truncated
- Document new log flags: --prompts, --agent, --session - Document session pagination: --session-offset, --session-limit - Document git notes namespaces for AI metadata - Update agent mode docs to reflect auto-detection from environment - Clarify ZAGI_AGENT is for executor selection, agent mode is auto-detected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds the
zagi agentcommand suite for AI-assisted task planning and execution using the RALPH pattern (Recursive Agent Loop Pattern for Humans).New Commands
zagi agent plan- Interactive planning sessions with AIzagi agent run- Automated task execution loopzagi tasks import- Import tasks from markdown plan filesUsage
Planning with
agent planStart an interactive planning session where an AI agent helps you design and create tasks:
The planning agent follows a collaborative protocol:
Running tasks with
agent runExecute the RALPH loop to automatically complete pending tasks:
Importing tasks from plans
Convert a markdown plan file into tasks:
# Import tasks from a plan file zagi tasks import plan.mdExecutor Configuration
Control which AI executes tasks:
Agent Safety Features
When
ZAGI_AGENTis set:tasks editappends instead of replacing (prevents accidental overwrites)reset --hard,push --force,clean -f, etc.git commitrequires--promptflagTest Plan
agent plan --dry-runagent runwith mocked executorZAGI_AGENT_CMDoverrideGenerated with Claude Code