feat: local drafter (pi against an OpenAI-compatible server on your own hardware)
tests / unittest (push) Failing after 28s

drafter: local runs the pi agent against the model already loaded on a self-hosted server,
as an unprivileged user, in the same sandbox as the Claude drafter. It fails soft when the
server is unreachable or has no model loaded. Both drafters now refuse to continue if
git metadata changed during drafting, and strip project pi configuration from the sandbox.
Tested live against a self-hosted server: one run, 12 turns, docs PR opened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 17:12:42 -05:00
1 parent 9dea56ce98
commit 1ef68f12fb
14 files changed
+1303 -42

No files matched your search

+29 -4
View File
@@ -3,9 +3,10 @@
# caller and the inputs.
#
# Secrets reach only the steps that need them. The bot token is in the clone step and
# the two steps that run the tool. The Claude credentials are in the drafting step only,
# and that step runs only when `drafter` normalizes to `claude`. Every `if:` reads the
# normalized drafter, never the raw input.
# the two steps that run the tool. The Claude credentials and the local model key are in
# the drafting step only: the Claude ones only when `drafter` normalizes to `claude`, the
# local key only when it normalizes to `local`. Every `if:` and secret expression reads
# the normalized drafter, never the raw input.
name: docs-review
on:
@@ -55,6 +56,11 @@ on:
type: string
required: false
default: ""
local_url:
description: "OpenAI-compatible base URL of the model server for drafter: local, e.g. http://model-host:8888/v1"
type: string
required: false
default: ""
model:
description: "Model for drafter: claude"
type: string
@@ -75,6 +81,8 @@ on:
required: false
ANTHROPIC_API_KEY:
required: false
LOCAL_MODEL_API_KEY:
required: false
defaults:
run:
@@ -106,6 +114,7 @@ jobs:
INPUT_TRACKING_ISSUE: ${{ inputs.tracking_issue }}
INPUT_DOC_GUIDE: ${{ inputs.doc_guide }}
INPUT_MODEL: ${{ inputs.model }}
INPUT_LOCAL_URL: ${{ inputs.local_url }}
# The calling repository's files are untrusted. Every python3 call takes -P, so
# Python imports nothing from the working directory and a docs_review/ or os.py in
# a pull request cannot replace the tool.
@@ -201,7 +210,10 @@ jobs:
&& steps.drafter.outputs.drafter != 'none'
run: sleep 180
# `local` runs here too, without the Claude credentials and without the install.
# `claude` gets the Claude credentials and the Claude Code install; `local` gets the
# local model key, the pi install and an unprivileged user to run pi as. pi's tool
# allowlist limits tool types, not paths, so the user is what keeps it out of the
# checkout: the checkout is root-owned and not writable by that user.
- name: Draft
if: >-
steps.drafter.outputs.drafter != 'none'
@@ -212,7 +224,10 @@ jobs:
DOCS_REVIEW_BOT_TOKEN: ${{ secrets.DOCS_REVIEW_BOT_TOKEN }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ steps.drafter.outputs.drafter == 'claude' && secrets.CLAUDE_CODE_OAUTH_TOKEN || '' }}
ANTHROPIC_API_KEY: ${{ steps.drafter.outputs.drafter == 'claude' && secrets.ANTHROPIC_API_KEY || '' }}
LOCAL_MODEL_API_KEY: ${{ steps.drafter.outputs.drafter == 'local' && secrets.LOCAL_MODEL_API_KEY || '' }}
DOCS_REVIEW_DRAFTER_USER: ${{ steps.drafter.outputs.drafter == 'local' && 'docs-review-drafter' || '' }}
CLAUDE_CODE_VERSION: 2.1.322
PI_VERSION: 1.5.2
DISABLE_UPDATES: "1"
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1"
run: |
@@ -226,6 +241,16 @@ jobs:
npm install -g --no-fund --no-audit "@anthropic-ai/claude-code@$CLAUDE_CODE_VERSION"
claude --version
fi
# Without the key the tool posts the flags with a note and fails before pi runs.
if [ "$DRAFTER" = "local" ] && [ -n "$LOCAL_MODEL_API_KEY" ]; then
npm install -g --no-fund --no-audit "@earendil-works/pi-coding-agent@$PI_VERSION"
pi --version < /dev/null
id -u "$DOCS_REVIEW_DRAFTER_USER" >/dev/null 2>&1 \
|| useradd --create-home --shell /usr/sbin/nologin "$DOCS_REVIEW_DRAFTER_USER"
# The user's sandbox and HOME are created under RUNNER_TEMP; it needs to
# traverse it, not list it.
chmod o+x "$RUNNER_TEMP"
fi
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${GITHUB_SERVER_URL}/.extraHeader" \
GIT_CONFIG_VALUE_0="Authorization: token $DOCS_REVIEW_BOT_TOKEN"
if [ "$EVENT" = "pull_request" ]; then