Skip to content

Deterministic /loop parsing bypassed in opencode run — documented guards (missing prompt, cron rejection, unknown flags) never fire #3

Deterministic /loop parsing bypassed in opencode run — documented guards (missing prompt, cron rejection, unknown flags) never fire

Deterministic /loop parsing bypassed in opencode run — documented guards (missing prompt, cron rejection, unknown flags) never fire #3

name: Auto-fix Issue (mini-swe-agent)
on:
issues:
types: [labeled]
permissions:
contents: write
pull-requests: write
issues: write
concurrency:
group: autofix-${{ github.event.issue.number }}
cancel-in-progress: true
jobs:
fix:
# Triggered by adding the "fix-me" label to an issue
if: github.event.label.name == 'fix-me'
runs-on: ubuntu-latest
timeout-minutes: 30 # hard cap so a stuck agent cannot burn runner minutes
steps:
- uses: actions/checkout@v4
- name: Setup Node (project test environment)
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Setup Python & mini-swe-agent
uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install mini-swe-agent
- name: Comment on issue (start)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue comment ${{ github.event.issue.number }} \
--body "🤖 mini-swe-agent (Kimi K3) has started working on this issue. A draft PR will be opened automatically when done."
- name: Run mini-swe-agent (Kimi K3)
env:
# Kimi K3 API (OpenAI-compatible endpoint, passed through via litellm openai/)
# Anthropic-compatible endpoint: https://api.kimi.com/coding/
KIMI_API_KEY: ${{ secrets.KIMI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.KIMI_API_KEY }}
OPENAI_BASE_URL: https://api.kimi.com/coding/v1
# Skip the interactive first-run setup wizard (aborts in non-TTY CI);
# MSWEA_CONFIGURED is the actual bypass flag, MSWEA_MODEL_NAME sets the model
MSWEA_CONFIGURED: "true"
MSWEA_MODEL_NAME: openai/k3-256k
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
# Git identity for commits made by the agent (runner has none by default)
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Write the issue to /tmp instead of embedding it in the shell script,
# so arbitrary issue content (quotes, EOF lines, etc.) cannot break parsing
gh issue view "$ISSUE_NUMBER" --json title,body \
-q '.title + "\n\n" + .body' > /tmp/issue.md
TASK=$(cat <<EOF
You are a maintainer of this repository. Fix GitHub issue #${ISSUE_NUMBER},
whose full text is saved at /tmp/issue.md (read it first: cat /tmp/issue.md).
Project context: an opencode plugin written in TypeScript (a /loop command
that runs prompts on a schedule).
- Build: npm run build
- Test: npm test (must pass after your changes)
Rules:
1. Read the relevant source code first, identify the root cause, and apply
a minimal fix. Do not refactor, reformat, or touch unrelated files.
2. Run npm test and make sure everything passes; iterate if it fails.
3. Commit your fix and open a draft PR:
git checkout -b fix/issue-${ISSUE_NUMBER} || git checkout fix/issue-${ISSUE_NUMBER}
git add -A && git commit -m "fix: resolve issue #${ISSUE_NUMBER}"
git push -u origin fix/issue-${ISSUE_NUMBER}
gh pr create --title "fix: resolve issue #${ISSUE_NUMBER}" \
--body "Auto-generated by mini-swe-agent (Kimi K3). Please review carefully.\n\ncloses #${ISSUE_NUMBER}" \
--draft
4. NEVER push to main, NEVER use git push --force, and NEVER modify
files under .github/workflows/.
EOF
)
mini -t "$TASK" \
--model openai/k3-256k \
--yolo \
--cost-limit 0 \
--output "traj-${ISSUE_NUMBER}.json" || true
- name: Upload trajectory
if: always()
uses: actions/upload-artifact@v4
with:
name: traj-${{ github.event.issue.number }}
path: traj-*.json
retention-days: 30
- name: Comment on issue (result)
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
PR_URL=$(gh pr list --head "fix/issue-${ISSUE_NUMBER}" --json url -q '.[0].url')
if [ -n "$PR_URL" ]; then
gh issue comment "$ISSUE_NUMBER" --body "✅ Fix PR created: ${PR_URL} — please review before merging."
else
gh issue comment "$ISSUE_NUMBER" --body "⚠️ The agent could not complete the fix (step/cost limit reached or root cause unclear). See the trajectory artifact in this workflow run for details; feel free to add more context to the issue and retry."
fi