Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7ce4906
Add automated TODO management example for GitHub Actions
openhands-agent Oct 16, 2025
5559427
Update TODO comment format to 'in progress' instead of just PR URL
openhands-agent Oct 16, 2025
0d26f7f
Simplify TODO management example
openhands-agent Oct 16, 2025
e1a4fa3
Drastically simplify TODO scanner implementation
openhands-agent Oct 16, 2025
3b23f85
Use GitHub API to extract branch info from PR URL
openhands-agent Oct 16, 2025
61ef6f8
Simplify branch detection using git current branch
openhands-agent Oct 16, 2025
ebd79b7
update
simonrosenberg Oct 16, 2025
c5d8c26
update
simonrosenberg Oct 16, 2025
24e00f8
Merge branch 'main' into openhands/todo-management-example
simonrosenberg Oct 16, 2025
aaeab4c
Add debug script for TODO management workflow
openhands-agent Oct 16, 2025
07e147e
Add comprehensive logging to TODO management workflow
openhands-agent Oct 16, 2025
20a9474
Complete TODO management example with comprehensive documentation
openhands-agent Oct 16, 2025
16a2bd1
Fix pre-commit issues in TODO management example
openhands-agent Oct 16, 2025
e784c55
Complete TODO management implementation with comprehensive testing
openhands-agent Oct 16, 2025
0ec7c79
Enhance scanner filtering to ignore processed TODOs
openhands-agent Oct 16, 2025
8d33f1d
Add PR label trigger for TODO management workflow
openhands-agent Oct 16, 2025
70d7aac
Update LLM configuration for TODO management workflow
openhands-agent Oct 16, 2025
3f0a2bb
Fix missing dependencies in build system
openhands-agent Oct 16, 2025
b239105
Add comprehensive build dependencies for tools package
openhands-agent Oct 16, 2025
60ce7ab
Enhance TODO scanner to handle multi-line comments
openhands-agent Oct 16, 2025
47dd5f4
Add comprehensive TODO and PR summary to GitHub Actions
openhands-agent Oct 16, 2025
865c474
Fix artifact name validation error
openhands-agent Oct 16, 2025
f919e52
Suppress annoying Pydantic serialization warnings
openhands-agent Oct 16, 2025
05dcc5d
no-verify
simonrosenberg Oct 16, 2025
058b8b4
fix
simonrosenberg Oct 16, 2025
df2c539
Fix GitHub Actions workflow syntax error
openhands-agent Oct 16, 2025
de3447f
update prompt readme
simonrosenberg Oct 16, 2025
f567168
Merge branch 'openhands/todo-management-example' of github.com:All-Ha…
simonrosenberg Oct 16, 2025
c8b82fe
Remove direct main branch modification logic
openhands-agent Oct 16, 2025
dd300e8
Clean up TODO management example - remove non-essential files
openhands-agent Oct 16, 2025
f58187f
Implement remote runtime for TODO management to solve GitHub permissions
openhands-agent Oct 16, 2025
852b2a6
Add test TODO for remote runtime verification
openhands-agent Oct 16, 2025
1f20b6a
Revert "Add test TODO for remote runtime verification"
simonrosenberg Oct 16, 2025
37f1542
Revert "Implement remote runtime for TODO management to solve GitHub …
simonrosenberg Oct 16, 2025
77248b5
Merge branch 'main' into openhands/todo-management-example
simonrosenberg Oct 16, 2025
7c46ed4
Fix pre-commit hook issues in TODO management example
openhands-agent Oct 16, 2025
1d422e7
revert changes
simonrosenberg Oct 16, 2025
0686fd1
update
simonrosenberg Oct 16, 2025
7a38684
update
simonrosenberg Oct 16, 2025
52df0d4
Fix malformed URLs in todo-management workflow
openhands-agent Oct 16, 2025
ef10737
Fix ModuleNotFoundError by installing openhands-tools package
openhands-agent Oct 16, 2025
c8ad742
Merge branch 'main' into openhands/todo-management-example
simonrosenberg Oct 16, 2025
e2fabb2
Fix package installation using uv and git repository
openhands-agent Oct 16, 2025
d0611ba
Fix YAML formatting to pass pre-commit checks
openhands-agent Oct 16, 2025
0a3794f
Fix agent script argument format
openhands-agent Oct 16, 2025
b77ddf0
Add missing GITHUB_REPOSITORY environment variable
openhands-agent Oct 16, 2025
34e3c33
Add comprehensive logging and error capture for agent execution
openhands-agent Oct 16, 2025
5fb9333
Add comprehensive error handling and debugging to agent script
openhands-agent Oct 16, 2025
84396cb
Clean up agent code by removing excessive error handling
openhands-agent Oct 16, 2025
89ea2df
Ensure agent starts from main branch, not current workflow branch
openhands-agent Oct 16, 2025
bd133e2
Fix workflow to check for open PRs instead of just branch existence
openhands-agent Oct 16, 2025
ac5f332
Remove all skipping logic from TODO workflow
openhands-agent Oct 16, 2025
e4036a7
Fix agent conversation initialization - add cli_mode and workspace
openhands-agent Oct 16, 2025
84b8e5d
Fix agent execution directory - run from repository not /tmp
openhands-agent Oct 16, 2025
787c06c
Simplify LLM configuration and conversation setup
openhands-agent Oct 16, 2025
4301caf
update
simonrosenberg Oct 16, 2025
047419e
update
simonrosenberg Oct 16, 2025
23c93da
Merge branch 'openhands/todo-management-example' of github.com:All-Ha…
simonrosenberg Oct 16, 2025
212d151
Fix all pre-commit checks
openhands-agent Oct 16, 2025
cc3640b
update
simonrosenberg Oct 17, 2025
72c8543
Fix TODO processing after removing todo_text field
openhands-agent Oct 17, 2025
a928379
Simplify TODO scanner by removing complex filtering logic
openhands-agent Oct 17, 2025
d79fefd
Remove unused file_pattern input from TODO management workflow
openhands-agent Oct 17, 2025
4bd4faa
Restore simplified scanner and tests after accidental revert
openhands-agent Oct 17, 2025
b61e21b
Add Rust support and configurable TODO identifiers
openhands-agent Oct 17, 2025
d9b455d
Add comprehensive tests for Rust support and custom identifiers
openhands-agent Oct 17, 2025
a8b4ea1
Merge branch 'main' into openhands/todo-management-example
simonrosenberg Oct 17, 2025
4f180b0
Fix YAML formatting with yamlfmt
openhands-agent Oct 17, 2025
d72a86a
Fix scanner path filtering to exclude example files
openhands-agent Oct 17, 2025
af40091
pre-commit run
simonrosenberg Oct 17, 2025
6cdd767
Merge branch 'main' into openhands/todo-management-example
simonrosenberg Oct 17, 2025
0edc67b
Merge branch 'main' into openhands/todo-management-example
simonrosenberg Oct 17, 2025
67b6fe7
rename
simonrosenberg Oct 17, 2025
19c2853
Simplify TODO management agent script
openhands-agent Oct 17, 2025
4a7aab9
Update TODO management workflow for repository reorganization
openhands-agent Oct 17, 2025
41ea918
Fix scanner exclusion path after repository reorganization
openhands-agent Oct 17, 2025
8da212d
remove scan download
simonrosenberg Oct 17, 2025
f859b88
Merge branch 'openhands/todo-management-example' of github.com:All-Ha…
simonrosenberg Oct 17, 2025
6304dd1
Fix file paths in workflow: Use correct examples/03_github_workflows …
simonrosenberg Oct 17, 2025
0d4a7e6
Fix package installation paths: Use correct subdirectory names
simonrosenberg Oct 17, 2025
15bb5af
Fix workflow branch: Use feature branch with TODO management files
simonrosenberg Oct 17, 2025
713ff9f
update
simonrosenberg Oct 17, 2025
2e0fe87
Merge branch 'openhands/todo-management-example' of github.com:All-Ha…
simonrosenberg Oct 17, 2025
dd35061
update
simonrosenberg Oct 17, 2025
6e048f1
update prompt
simonrosenberg Oct 17, 2025
006a9e0
Simplify TODO management agent script to match basic action pattern
simonrosenberg Oct 17, 2025
3888595
Add tests for Agent.init_state in-place state modification
Oct 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/pr-review-by-openhands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
if: github.event.label.name == 'review-this'
runs-on: ubuntu-latest
env:
# Configuration (modify these values as needed)
LLM_MODEL: litellm_proxy/claude-sonnet-4-5-20250929
LLM_BASE_URL: https://llm-proxy.eval.all-hands.dev
# PR context will be automatically provided by the agent script
Expand Down
322 changes: 322 additions & 0 deletions .github/workflows/todo-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
---
# Automated TODO Management Workflow
#
# This workflow automatically scans for TODO(openhands) comments and creates
# pull requests to implement them using the OpenHands agent.
#
# Setup:
# 1. Add LLM_API_KEY to repository secrets
# 2. Ensure GITHUB_TOKEN has appropriate permissions
# 3. Make sure Github Actions are allowed to create and review PRs
# 4. Commit this file to .github/workflows/ in your repository
# 5. Configure the schedule or trigger manually

name: Automated TODO Management

on:
# Manual trigger
workflow_dispatch:
inputs:
max_todos:
description: Maximum number of TODOs to process in this run
required: false
default: '3'
type: string
todo_identifier:
description: TODO identifier to search for (e.g., TODO(openhands))
required: false
default: TODO(openhands)
type: string

# Trigger when 'automatic-todo' label is added to a PR
pull_request:
types: [labeled]

# Scheduled trigger (disabled by default, uncomment and customize as needed)
# schedule:
# # Run every Monday at 9 AM UTC
# - cron: "0 9 * * 1"

permissions:
contents: write
pull-requests: write
issues: write

jobs:
scan-todos:
runs-on: ubuntu-latest
# Only run if triggered manually or if 'automatic-todo' label was added
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.label.name == 'automatic-todo')
outputs:
todos: ${{ steps.scan.outputs.todos }}
todo-count: ${{ steps.scan.outputs.todo-count }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better context

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Copy TODO scanner
run: |
cp examples/03_github_workflows/03_todo_management/scanner.py /tmp/scanner.py
chmod +x /tmp/scanner.py

- name: Scan for TODOs
id: scan
run: |
echo "Scanning for TODO comments..."

# Run the scanner and capture output
TODO_IDENTIFIER="${{ github.event.inputs.todo_identifier || 'TODO(openhands)' }}"
python /tmp/scanner.py . --identifier "$TODO_IDENTIFIER" > todos.json

# Count TODOs
TODO_COUNT=$(python -c \
"import json; data=json.load(open('todos.json')); print(len(data))")
echo "Found $TODO_COUNT $TODO_IDENTIFIER items"

# Limit the number of TODOs to process
MAX_TODOS="${{ github.event.inputs.max_todos || '3' }}"
if [ "$TODO_COUNT" -gt "$MAX_TODOS" ]; then
echo "Limiting to first $MAX_TODOS TODOs"
python -c "
import json
data = json.load(open('todos.json'))
limited = data[:$MAX_TODOS]
json.dump(limited, open('todos.json', 'w'), indent=2)
"
TODO_COUNT=$MAX_TODOS
fi

# Set outputs
echo "todos=$(cat todos.json | jq -c .)" >> $GITHUB_OUTPUT
echo "todo-count=$TODO_COUNT" >> $GITHUB_OUTPUT

# Display found TODOs
echo "## 📋 Found TODOs" >> $GITHUB_STEP_SUMMARY
if [ "$TODO_COUNT" -eq 0 ]; then
echo "No TODO(openhands) comments found." >> $GITHUB_STEP_SUMMARY
else
echo "Found $TODO_COUNT TODO(openhands) items:" \
>> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
python -c "
import json
data = json.load(open('todos.json'))
for i, todo in enumerate(data, 1):
print(f'{i}. **{todo[\"file\"]}:{todo[\"line\"]}** - ' +
f'{todo[\"description\"]}')
" >> $GITHUB_STEP_SUMMARY
fi

process-todos:
needs: scan-todos
if: needs.scan-todos.outputs.todo-count > 0
runs-on: ubuntu-latest
strategy:
matrix:
todo: ${{ fromJson(needs.scan-todos.outputs.todos) }}
max-parallel: 1 # Process one TODO at a time to avoid conflicts
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Switch to feature branch with TODO management files
run: |
git checkout openhands/todo-management-example
git pull origin openhands/todo-management-example

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Install OpenHands dependencies
run: |
# Install OpenHands SDK and tools from git repository
uv pip install --system "openhands-sdk @ git+https://github.com/All-Hands-AI/agent-sdk.git@main#subdirectory=openhands-sdk"
uv pip install --system "openhands-tools @ git+https://github.com/All-Hands-AI/agent-sdk.git@main#subdirectory=openhands-tools"

- name: Copy agent files
run: |
cp examples/03_github_workflows/03_todo_management/agent_script.py agent.py
cp examples/03_github_workflows/03_todo_management/prompt.py prompt.py
chmod +x agent.py

- name: Configure Git
run: |
git config --global user.name "openhands-bot"
git config --global user.email \
"[email protected]"

- name: Process TODO
env:
LLM_MODEL: litellm_proxy/claude-sonnet-4-5-20250929
LLM_BASE_URL: https://llm-proxy.eval.all-hands.dev
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
TODO_FILE: ${{ matrix.todo.file }}
TODO_LINE: ${{ matrix.todo.line }}
TODO_DESCRIPTION: ${{ matrix.todo.description }}
PYTHONPATH: ''
run: |
echo "Processing TODO: $TODO_DESCRIPTION"
echo "File: $TODO_FILE:$TODO_LINE"

# Create a unique branch name for this TODO
BRANCH_NAME="todo/$(echo "$TODO_DESCRIPTION" | \
sed 's/[^a-zA-Z0-9]/-/g' | \
sed 's/--*/-/g' | \
sed 's/^-\|-$//g' | \
tr '[:upper:]' '[:lower:]' | \
cut -c1-50)"
echo "Branch name: $BRANCH_NAME"

# Create and switch to new branch (force create if exists)
git checkout -B "$BRANCH_NAME"

# Run the agent to process the TODO
# Stay in repository directory for git operations

# Create JSON payload for the agent
TODO_JSON=$(cat <<EOF
{
"file": "$TODO_FILE",
"line": $TODO_LINE,
"description": "$TODO_DESCRIPTION"
}
EOF
)

echo "JSON payload for agent:"
echo "$TODO_JSON"

# Debug environment and setup
echo "Current working directory: $(pwd)"
echo "Environment variables:"
echo " LLM_MODEL: $LLM_MODEL"
echo " LLM_BASE_URL: $LLM_BASE_URL"
echo " GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
echo " LLM_API_KEY: ${LLM_API_KEY:+[SET]}"
echo " GITHUB_TOKEN: ${GITHUB_TOKEN:+[SET]}"
echo "Available files:"
ls -la

# Run the agent with comprehensive logging
echo "Starting agent execution..."
set +e # Don't exit on error, we want to capture it
uv run python agent.py "$TODO_JSON" 2>&1 | tee agent_output.log
AGENT_EXIT_CODE=$?
set -e

echo "Agent exit code: $AGENT_EXIT_CODE"
echo "Agent output log:"
cat agent_output.log

# Show files in working directory
echo "Files in working directory:"
ls -la

# If agent failed, show more details
if [ $AGENT_EXIT_CODE -ne 0 ]; then
echo "Agent failed with exit code $AGENT_EXIT_CODE"
echo "Last 50 lines of agent output:"
tail -50 agent_output.log
exit $AGENT_EXIT_CODE
fi

# Check if any changes were made
cd "$GITHUB_WORKSPACE"
if git diff --quiet; then
echo "No changes made by agent, skipping PR creation"
exit 0
fi

# Commit changes
git add -A
git commit -m "Implement TODO: $TODO_DESCRIPTION

Automatically implemented by OpenHands agent.

Co-authored-by: openhands <[email protected]>"

# Push branch
git push origin "$BRANCH_NAME"

# Create pull request
PR_TITLE="Implement TODO: $TODO_DESCRIPTION"
PR_BODY="## 🤖 Automated TODO Implementation

This PR automatically implements the following TODO:

**File:** \`$TODO_FILE:$TODO_LINE\`
**Description:** $TODO_DESCRIPTION

### Implementation
The OpenHands agent has analyzed the TODO and implemented the
requested functionality.

### Review Notes
- Please review the implementation for correctness
- Test the changes in your development environment
- The original TODO comment will be updated with this PR URL
once merged

---
*This PR was created automatically by the TODO Management workflow.*"

# Create PR using GitHub CLI or API
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls" \
-d "{
\"title\": \"$PR_TITLE\",
\"body\": \"$PR_BODY\",
\"head\": \"$BRANCH_NAME\",
\"base\": \"${{ github.ref_name }}\"
}"

summary:
needs: [scan-todos, process-todos]
if: always()
runs-on: ubuntu-latest
steps:
- name: Generate Summary
run: |
echo "# 🤖 TODO Management Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

TODO_COUNT="${{ needs.scan-todos.outputs.todo-count || '0' }}"
echo "**TODOs Found:** $TODO_COUNT" >> $GITHUB_STEP_SUMMARY

if [ "$TODO_COUNT" -gt 0 ]; then
echo "**Processing Status:** ✅ Completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check the pull requests created for each TODO" \
"implementation." >> $GITHUB_STEP_SUMMARY
else
echo "**Status:** ℹ️ No TODOs found to process" \
>> $GITHUB_STEP_SUMMARY
fi

echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "*Workflow completed at $(date)*" >> $GITHUB_STEP_SUMMARY
4 changes: 2 additions & 2 deletions examples/03_github_workflows/02_pr_review/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ jobs:
- name: Install OpenHands dependencies
run: |
# Install OpenHands SDK and tools from git repository
uv pip install --system "openhands-sdk @ git+https://github.com/All-Hands-AI/agent-sdk.git@main#subdirectory=openhands/sdk"
uv pip install --system "openhands-tools @ git+https://github.com/All-Hands-AI/agent-sdk.git@main#subdirectory=openhands/tools"
uv pip install --system "openhands-sdk @ git+https://github.com/All-Hands-AI/agent-sdk.git@main#subdirectory=openhands-sdk"
uv pip install --system "openhands-tools @ git+https://github.com/All-Hands-AI/agent-sdk.git@main#subdirectory=openhands-tools"

- name: Check required configuration
env:
Expand Down
Loading