Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
77daad0
initial implementation
virajmehta Oct 19, 2025
6808acb
added missing files
virajmehta Oct 19, 2025
fcb532c
include PR description in markdown context
virajmehta Oct 20, 2025
5e80b8b
use `uv` for the whole python part
virajmehta Oct 20, 2025
00d718d
removed masking code
virajmehta Oct 20, 2025
dc8ed70
added better git handling
virajmehta Oct 20, 2025
5decf50
added git client oops
virajmehta Oct 20, 2025
91f0530
improved naming for git-related files
virajmehta Oct 20, 2025
9472f73
added TODO for instance template
virajmehta Oct 20, 2025
bbb06ee
removed darwin flag
virajmehta Oct 20, 2025
6250ff8
added pr number to the inference tags
virajmehta Oct 20, 2025
eeffd95
fixed uv dependencies on mini-swe-agent
virajmehta Oct 20, 2025
e090b8d
added local runner for CI Bot for testing and experimentation
virajmehta Oct 20, 2025
f95b805
removed dist/ from repo
virajmehta Oct 20, 2025
8512eea
added to ignores
virajmehta Oct 20, 2025
e988c23
cleaned up types
virajmehta Oct 20, 2025
df2e0b1
fixed dependency on my swe-agent fork
virajmehta Oct 20, 2025
8b22a9a
bot does recognizably interesting stuff locally
virajmehta Oct 20, 2025
4ccf56c
failure logs come in smoothly now
virajmehta Oct 20, 2025
d6dfb12
added instructions for machine readable itmeouts
virajmehta Oct 20, 2025
21ccb58
updated agent output
virajmehta Oct 21, 2025
ea3b209
added test-mode
virajmehta Oct 21, 2025
4a168c2
pr only
virajmehta Oct 21, 2025
eea8480
removed any suggestion comments from CI bot
virajmehta Oct 21, 2025
73dc205
fix type issues
virajmehta Oct 21, 2025
8b5079c
removed trajectory json
virajmehta Oct 21, 2025
e6fa8c2
added extra files
virajmehta Oct 21, 2025
18ba059
added docker compose
virajmehta Oct 21, 2025
232d8bb
added fix details section to PR comment
virajmehta Oct 21, 2025
bf9820b
added build files
virajmehta Oct 22, 2025
0ea8d1d
fixed lint errors
virajmehta Oct 22, 2025
7fab6ae
fixed linting errors
virajmehta Oct 24, 2025
42b7b30
added episode id handling
virajmehta Oct 24, 2025
c3a3c34
added episode id write to CH
virajmehta Oct 24, 2025
2f12705
Fix tests
shuyangli Nov 7, 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
29 changes: 24 additions & 5 deletions .github/workflows/ci-failure-diagnosis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@ jobs:
sparse-checkout: |
tensorzero

- name: Move tensorzero to tensorzero-for-gateway
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

- name: Create venv and install mini-swe-agent
run: |
mv ./tensorzero /tmp/tensorzero-for-gateway
ls -lR .
uv venv
uv pip install git+https://github.com/SWE-agent/mini-swe-agent.git@main

- name: Move tensorzero config to /tmp
run: |
mv ./tensorzero/swe_agent_config /tmp/tensorzero-for-gateway
ls -lR /tmp/tensorzero-for-gateway

- name: Start TensorZero gateway
run: |
Expand All @@ -36,6 +51,7 @@ jobs:
--name tensorzero-gateway \
-e TENSORZERO_CLICKHOUSE_URL=${{ secrets.CI_BOT_CLICKHOUSE_URL }} \
-e OPENAI_API_KEY=${{ secrets.CI_BOT_OPENAI_API_KEY }} \
-e ANTHROPIC_API_KEY=${{ secrets.CI_BOT_ANTHROPIC_API_KEY }} \
-p 3000:3000 \
--volume /tmp/tensorzero-for-gateway:/action-config \
tensorzero/gateway:latest --config-file /action-config/tensorzero.toml
Expand All @@ -58,9 +74,12 @@ jobs:
run: |
ls -lR /tmp/tensorzero-for-gateway
cat /tmp/tensorzero-for-gateway/tensorzero.toml
cat /tmp/tensorzero-for-gateway/prompt.minijinja
cat /tmp/tensorzero-for-gateway/templates/system.minijinja
cat /tmp/tensorzero-for-gateway/templates/instance.minijinja
which mini || echo "mini-swe-agent not found in PATH"
mini --help || echo "mini-swe-agent not working"

- name: Call LLM to generate PR revision
- name: Run mini-swe-agent to fix CI failures
uses: tensorzero/experimental-ci-bot/generate-pr-patch@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/provide-pull-request-feedback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ jobs:
--name tensorzero-gateway \
-e TENSORZERO_CLICKHOUSE_URL=${{ secrets.CI_BOT_CLICKHOUSE_URL }} \
-e OPENAI_API_KEY=${{ secrets.CI_BOT_OPENAI_API_KEY }} \
-e ANTHROPIC_API_KEY=${{ secrets.CI_BOT_ANTHROPIC_API_KEY }} \
-p 3000:3000 \
--volume ./tensorzero:/action-config \
--volume ./tensorzero/swe_agent_config:/action-config \
tensorzero/gateway:latest --config-file /action-config/tensorzero.toml

for _i in {1..100}; do
Expand Down
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Dependency directory
node_modules


# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
Expand Down Expand Up @@ -100,3 +101,14 @@ __tests__/runner/*
# IDE files
.idea
*.code-workspace

# Python
.venv
venv
env
__pycache__
*.py[cod]
*$py.class
*.so
.Python
.envrc
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
dist/
node_modules/
coverage/

# Python
.venv/
venv/
env/
__pycache__/
*.pyc
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,111 @@
[![CodeQL](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/actions/typescript-action/actions/workflows/codeql-analysis.yml)
[![Coverage](./badges/coverage.svg)](./badges/coverage.svg)

## Running Locally

You can run the mini-swe-agent locally to test PRs before deploying to GitHub
Actions.

### Prerequisites

1. Install dependencies:

```bash
npm install
npm run bundle # Build the CLI
```

1. Set up required environment variables:

```bash
# GitHub authentication (choose one):
export GITHUB_TOKEN=$(gh auth token) # If using gh CLI
# OR
export GITHUB_TOKEN=ghp_your_token_here

# Model API keys (at least one required):
export ANTHROPIC_API_KEY=your_anthropic_key
# OR
export OPENAI_API_KEY=your_openai_key
```

### Usage

#### Dry Run (Local Testing)

Test the agent without creating PRs or comments on GitHub:

```bash
npm run cli -- --repo owner/repo --pr 123 --dry-run
```

This will:

- Clone the PR repository
- Run the mini-swe-agent to analyze and fix issues
- Display the generated patch locally
- Not make any changes to GitHub

#### Live Mode (Create PRs/Comments)

Run the agent and create actual PRs or inline comments on GitHub:

```bash
npm run cli -- --repo owner/repo --pr 456
```

This will:

- Clone the PR repository
- Run the mini-swe-agent
- Create a follow-up PR or post inline comments based on the agent's decision

#### With CI Failure Context

If you have a specific workflow run that failed, you can provide its ID:

```bash
npm run cli -- --repo owner/repo --pr 789 --workflow-run-id 12345
```

### CLI Options

```text
-r, --repo <owner/repo> Repository in "owner/repo" format
-p, --pr <number> Pull request number (required)
-d, --dry-run Show patch locally without PRs/comments
-t, --token <token> GitHub token (default: GITHUB_TOKEN or gh)
-w, --workflow-run-id <id> Workflow run ID for failure logs
-o, --output-dir <path> Directory for debug artifacts
--clickhouse-url <url> ClickHouse URL for tracking
--clickhouse-table <name> ClickHouse table name
-c, --cost-limit <dollars> Cost limit (default: 3.0)
--timeout <minutes> Timeout in minutes (default: 30)
-h, --help Show help message
```

### Examples

```bash
# Dry run on a public repository
npm run cli -- --repo tensorzero/tensorzero --pr 100 --dry-run

# Run on your own repository with custom settings
export GITHUB_TOKEN=$(gh auth token)
npm run cli -- \
--repo myorg/myrepo \
--pr 42 \
--cost-limit 5.0 \
--timeout 45 \
--output-dir ./debug-output

# Analyze a specific failed workflow run
npm run cli -- \
--repo owner/repo \
--pr 123 \
--workflow-run-id 9876543210
```

## Developing

- `npm install`
Expand Down
Loading