Files
Liti-agent-Development/.gitea/workflows/run-agent.yml
T
jsahnandClaude Opus 4.8 a96ac2067f fix: default api_base to internal backend URL to bypass OAuth proxy
The public URL (legalpoc.eroomai.com) sits behind a Google OAuth proxy,
so CI requests get 302-redirected to the login page. Point api_base at the
internal backend (http://localhost:8800, served at root without /api prefix)
which the act_runner reaches on the same host. Documents host.docker.internal
and Tailscale fallbacks for containerized runners.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 13:43:42 +09:00

118 lines
4.7 KiB
YAML

# 지정한 Agent YAML 을 AgentBackend API 로 실행하는 Gitea Actions 워크플로우.
#
# 사용법: Gitea 저장소 → Actions 탭 → "Run Agent YAML via API" → Run workflow
# yaml_path 에 repo 상대경로 입력, 예:
# Case_02_Comparison_Research/YAML_Prompts/1. Stage_1/v.5/Stage_1_Part_4.yml
#
# 요구사항:
# - 저장소 설정에서 Actions 활성화 + act_runner 등록 (runs-on: ubuntu-latest 라벨)
# - 러너가 백엔드에 내부 주소로 접근 가능해야 함 (아래 api_base 참고)
#
# 인증 (중요):
# 공개 URL(https://legalpoc.eroomai.com)은 Google OAuth 프록시(auth.eroomai.com)
# 뒤에 있어서 CI 에서는 302 로 로그인 페이지로 튕긴다. 그래서 api_base 기본값을
# 프록시를 거치지 않는 내부 주소(http://localhost:8800)로 둔다.
# 내부 백엔드는 /api 접두사 없이 루트로 API 를 제공한다(/upload-agent, /sse/agent/...).
# ※ 러너 job 이 컨테이너 안에서 돌아 localhost 로 호스트에 못 닿으면
# api_base 를 http://host.docker.internal:8800 또는
# http://eroom-server.tailabbfd5.ts.net:8800 로 바꿔서 실행할 것.
#
# 실행 흐름 (SKILL.md §0.6 경로 A):
# upload-agent 등록 → SSE start → stage_complete 자동 confirm → execution_complete
# stage_error 발생 시 세션을 cancel 하고 실패 처리한다.
# 전체 이벤트 로그 / final_output / summary 는 아티팩트로 저장된다.
#
# 실행 시간 상한 (주의):
# Gitea 의 [actions] ENDLESS_TASK_TIMEOUT 과 act_runner 의 runner.timeout 기본값이
# 각각 3h 라서, timeout-minutes 를 아무리 크게 줘도 3h 에서 강제 종료된다.
# 강제 종료되면 if: always() 아티팩트 업로드도 건너뛰므로,
# 스크립트의 --max-runtime(기본 9000s=150m) 이 먼저 세션을 정리하고 종료하도록
# max_runtime < timeout-minutes(175m) < 3h 순서를 유지한다.
# 3h 이상 돌려야 하면: app.ini 의 ENDLESS_TASK_TIMEOUT, act_runner config 의
# runner.timeout, 아래 timeout-minutes, max_runtime 입력을 모두 함께 올릴 것.
name: Run Agent YAML via API
on:
workflow_dispatch:
inputs:
yaml_path:
description: '실행할 Agent YAML 경로 (repo 상대경로)'
required: true
type: string
user_id:
description: 'AgentBackend user_id'
required: false
default: 'jsahn'
type: string
workspace_id:
description: 'AgentBackend workspace_id'
required: false
default: 'e1d0baed-cec9-44af-9989-b7aab09bcfd1'
type: string
user_input:
description: 'Agent 에 전달할 user_input'
required: false
default: ''
type: string
start_stage_index:
description: '시작 stage 인덱스 (0-based)'
required: false
default: '0'
type: string
api_base:
description: 'AgentBackend API base URL (내부 주소, /api 접두사 없음)'
required: false
default: 'http://localhost:8800'
type: string
max_runtime_seconds:
description: '총 실행 시간 상한(초). Gitea/act_runner 3h 상한보다 짧게'
required: false
default: '9000'
type: string
jobs:
run-agent:
runs-on: ubuntu-latest
timeout-minutes: 175
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: python -m pip install --quiet httpx httpx-sse
- name: Run agent via API
env:
YAML_PATH: ${{ inputs.yaml_path }}
API_BASE: ${{ inputs.api_base }}
AGENT_USER_ID: ${{ inputs.user_id }}
AGENT_WORKSPACE_ID: ${{ inputs.workspace_id }}
AGENT_USER_INPUT: ${{ inputs.user_input }}
START_STAGE_INDEX: ${{ inputs.start_stage_index }}
MAX_RUNTIME_SECONDS: ${{ inputs.max_runtime_seconds }}
# '=' 형식 필수: user_input 이 '-' 로 시작하는 자유 텍스트여도 argparse 가 값으로 인식
run: |
python scripts/run_agent_api.py \
--yaml-path="$YAML_PATH" \
--api-base="$API_BASE" \
--user-id="$AGENT_USER_ID" \
--workspace-id="$AGENT_WORKSPACE_ID" \
--user-input="$AGENT_USER_INPUT" \
--start-stage-index="$START_STAGE_INDEX" \
--max-runtime="$MAX_RUNTIME_SECONDS" \
--output-dir=agent_run_output
- name: Upload run artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: agent-run-${{ github.run_number }}
path: agent_run_output/
if-no-files-found: warn