github-agentic-workflows

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub Agentic Workflows

GitHub Agentic Workflows

Skill by ara.so — AI Agent Skills collection.
GitHub Agentic Workflows (gh-aw) is a framework for creating AI-powered automation workflows that can autonomously maintain repositories, review code, triage issues, update documentation, and perform developer tasks. Workflows are defined in simple Markdown files and run as GitHub Actions.
ara.so提供的Skill——AI Agent技能合集。
GitHub Agentic Workflows(gh-aw)是一个用于创建AI驱动自动化工作流的框架,可自主维护代码仓库、审核代码、分类处理Issue、更新文档并执行各类开发者任务。工作流通过简单的Markdown文件定义,并以GitHub Actions的形式运行。

What It Does

功能介绍

  • Autonomous Repository Maintenance: AI agents that triage issues, label PRs, fix bugs, and maintain documentation
  • Code Review: Automated PR reviews with configurable personas (grumpy reviewer, nitpick reviewer, etc.)
  • CI/CD Intelligence: Monitor and diagnose CI failures, optimize workflows, track costs
  • Documentation: Auto-update docs, maintain wikis, check links, generate glossaries
  • Planning & Reporting: Generate status reports, research summaries, activity chronicles
  • Security: Scan for malicious code, generate VEX statements for security alerts
  • 自主仓库维护:AI Agent可分类处理Issue、为PR添加标签、修复Bug并维护文档
  • 代码审核:支持配置不同角色的自动化PR审核(如严苛审核员、细节审核员等)
  • CI/CD智能管理:监控并诊断CI失败问题、优化工作流、跟踪成本
  • 文档管理:自动更新文档、维护Wiki、检查链接有效性、生成术语表
  • 规划与报告:生成状态报告、研究摘要、活动记录
  • 安全检测:扫描恶意代码、为安全警报生成VEX声明

Installation

安装步骤

Prerequisites

前置条件

  1. GitHub repository with Actions enabled
  2. GitHub App or Personal Access Token with appropriate permissions
  3. Access to an AI model provider (OpenAI, Anthropic, etc.)
  1. 已启用Actions功能的GitHub代码仓库
  2. 拥有相应权限的GitHub App或个人访问令牌(Personal Access Token)
  3. 可访问AI模型提供商(如OpenAI、Anthropic等)

Basic Setup

基础配置

  1. Install the
    gh-aw
    CLI:
bash
undefined
  1. 安装
    gh-aw
    命令行工具:
bash
undefined

Using npm

使用npm安装

npm install -g @github/gh-aw
npm install -g @github/gh-aw

Or using GitHub CLI extension

或使用GitHub CLI扩展安装

gh extension install github/gh-aw

2. Create `.github/workflows` directory in your repository:

```bash
mkdir -p .github/workflows
  1. Copy a workflow from the Agentics collection:
bash
undefined
gh extension install github/gh-aw

2. 在代码仓库中创建`.github/workflows`目录:

```bash
mkdir -p .github/workflows
  1. 从Agentics合集中复制工作流:
bash
undefined

Example: Issue Triage workflow

示例:Issue分类处理工作流


4. Configure secrets in your repository settings:
   - `GITHUB_TOKEN` (automatically available)
   - `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` (for AI model access)

4. 在仓库设置中配置密钥:
   - `GITHUB_TOKEN`(自动提供)
   - `OPENAI_API_KEY`或`ANTHROPIC_API_KEY`(用于访问AI模型)

Workflow Structure

工作流结构

Agentic workflows consist of two files:
  1. YAML file (
    .github/workflows/*.yml
    ) - GitHub Actions configuration
  2. Markdown file (
    .github/workflows/*.md
    ) - Agent instructions and behavior
Agentic工作流包含两个文件:
  1. YAML文件
    .github/workflows/*.yml
    )- GitHub Actions配置文件
  2. Markdown文件
    .github/workflows/*.md
    )- Agent的指令与行为定义

Example: Issue Triage Workflow

示例:Issue分类处理工作流

.github/workflows/issue-triage.yml
:
yaml
name: Issue Triage
on:
  issues:
    types: [opened, edited]
  pull_request:
    types: [opened, edited]

jobs:
  triage:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/issue-triage.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
.github/workflows/issue-triage.md
:
markdown
undefined
.github/workflows/issue-triage.yml
:
yaml
name: Issue Triage
on:
  issues:
    types: [opened, edited]
  pull_request:
    types: [opened, edited]

jobs:
  triage:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/issue-triage.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
.github/workflows/issue-triage.md
:
markdown
undefined

Issue Triage Agent

Issue分类处理Agent

You are a helpful issue triage assistant. When a new issue or pull request is opened:
  1. Read the title and body carefully
  2. Analyze the content to determine appropriate labels
  3. Apply relevant labels from the repository's label set
  4. Add a welcoming comment if this is a first-time contributor
你是一名乐于助人的Issue分类处理助手。当新的Issue或PR创建时:
  1. 仔细阅读标题和内容
  2. 分析内容以确定合适的标签
  3. 从仓库的标签集中选择相关标签添加
  4. 如果是首次贡献者,添加欢迎评论

Available Tools

可用工具

  • github.issues.addLabels
    - Add labels to issues
  • github.issues.createComment
    - Comment on issues
  • github.pulls.requestReviewers
    - Request reviewers for PRs
  • github.issues.addLabels
    - 为Issue添加标签
  • github.issues.createComment
    - 在Issue下评论
  • github.pulls.requestReviewers
    - 为PR请求审核人员

Labels to Consider

可选择的标签

  • bug
    - Something isn't working
  • enhancement
    - New feature or request
  • documentation
    - Documentation improvements
  • good first issue
    - Good for newcomers
  • help wanted
    - Extra attention needed
  • bug
    - 功能异常
  • enhancement
    - 新功能需求
  • documentation
    - 文档改进
  • good first issue
    - 适合新手的任务
  • help wanted
    - 需要额外关注

Example Analysis

示例分析

For a bug report mentioning crashes, apply:
bug
, potentially
help wanted
For a feature request, apply:
enhancement
For documentation fixes, apply:
documentation
, potentially
good first issue
undefined
对于提到崩溃的Bug报告,添加标签:
bug
,可额外添加
help wanted
对于功能请求,添加标签:
enhancement
对于文档修复,添加标签:
documentation
,可额外添加
good first issue
undefined

Key Workflow Types

核心工作流类型

Maintainer Workflows

维护者工作流

Repo Assist - Comprehensive repository assistant:
yaml
name: Repo Assist
on:
  schedule:
    - cron: '0 */6 * * *'  # Every 6 hours
  issues:
    types: [opened, edited, labeled]
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  assist:
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/repo-assist.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Repo Assist - 全面的仓库助手:
yaml
name: Repo Assist
on:
  schedule:
    - cron: '0 */6 * * *'  # 每6小时运行一次
  issues:
    types: [opened, edited, labeled]
  pull_request:
    types: [opened, edited, synchronize]

jobs:
  assist:
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/repo-assist.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

Code Review Workflows

代码审核工作流

Grumpy Reviewer - On-demand opinionated reviews:
yaml
name: Grumpy Reviewer
on:
  issue_comment:
    types: [created]

jobs:
  review:
    if: contains(github.event.comment.body, '/grumpy-review')
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/grumpy-reviewer.md
Grumpy Reviewer - 按需提供个性化审核:
yaml
name: Grumpy Reviewer
on:
  issue_comment:
    types: [created]

jobs:
  review:
    if: contains(github.event.comment.body, '/grumpy-review')
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/grumpy-reviewer.md

Documentation Workflows

文档工作流

Daily Doc Updater:
yaml
name: Documentation Updater
on:
  schedule:
    - cron: '0 9 * * *'  # Daily at 9 AM
  workflow_dispatch:

jobs:
  update-docs:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/doc-updater.md
Daily Doc Updater:
yaml
name: Documentation Updater
on:
  schedule:
    - cron: '0 9 * * *'  # 每天上午9点运行
  workflow_dispatch:

jobs:
  update-docs:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/doc-updater.md

Custom Workflow Creation

自定义工作流创建

Basic Template

基础模板

markdown
undefined
markdown
undefined

My Custom Agent

我的自定义Agent

Role

角色

You are a [describe the agent's role and purpose].
你是[描述Agent的角色和目标]。

Triggers

触发条件

This workflow runs when [describe trigger conditions].
当[描述触发条件]时,此工作流运行。

Tasks

任务

  1. [First task description]
  2. [Second task description]
  3. [Third task description]
  1. [第一个任务描述]
  2. [第二个任务描述]
  3. [第三个任务描述]

Available Tools

可用工具

List the GitHub API tools you'll use:
  • github.issues.create
    - Create new issues
  • github.repos.createOrUpdateFileContents
    - Update files
  • github.pulls.create
    - Create pull requests
列出你将使用的GitHub API工具:
  • github.issues.create
    - 创建新Issue
  • github.repos.createOrUpdateFileContents
    - 更新文件
  • github.pulls.create
    - 创建PR

Guidelines

指导原则

  • [Guideline 1]
  • [Guideline 2]
  • [Guideline 3]
  • [指导原则1]
  • [指导原则2]
  • [指导原则3]

Output Format

输出格式

Provide results as:
  • Summary of actions taken
  • Links to created issues/PRs
  • Any recommendations
undefined
结果需包含:
  • 已执行操作的摘要
  • 已创建的Issue/PR链接
  • 任何建议
undefined

Using Shared Fragments

使用共享片段

Import reusable components:
markdown
undefined
导入可复用组件:
markdown
undefined

My Workflow

我的工作流

imports: [shared/formatting.md, shared/arxiv.md]
imports: [shared/formatting.md, shared/arxiv.md]

Tasks

任务

Use the arXiv MCP server to search for relevant papers on [topic]. Format the output using the standard formatting guidelines.
undefined
使用arXiv MCP服务器搜索与[主题]相关的论文。 使用标准格式指南格式化输出。
undefined

Advanced: MCP Server Integration

进阶:MCP服务器集成

markdown
undefined
markdown
undefined

Research Assistant

研究助手

imports: [shared/arxiv.md, shared/markitdown.md]
imports: [shared/arxiv.md, shared/markitdown.md]

Tasks

任务

  1. Search arXiv for papers on "machine learning optimization"
  2. Download the top 3 papers as PDFs
  3. Convert PDFs to Markdown using MarkItDown
  4. Summarize findings in an issue
  1. 在arXiv上搜索关于"machine learning optimization"的论文
  2. 下载排名前三的论文为PDF格式
  3. 使用MarkItDown将PDF转换为可读的Markdown
  4. 在Issue中总结研究结果

MCP Servers

MCP服务器

  • arxiv: Search and retrieve academic papers
  • markitdown: Convert PDFs to readable Markdown
undefined
  • arxiv: 搜索并获取学术论文
  • markitdown: 将PDF转换为可读的Markdown
undefined

Configuration

配置

Environment Variables

环境变量

Set in repository secrets or
.env
:
bash
undefined
在仓库密钥或
.env
文件中设置:
bash
undefined

Required

必填

GITHUB_TOKEN=ghp_your_token_here OPENAI_API_KEY=sk-your-key-here
GITHUB_TOKEN=ghp_your_token_here OPENAI_API_KEY=sk-your-key-here

Optional - Alternative AI providers

可选 - 替代AI提供商

ANTHROPIC_API_KEY=sk-ant-your-key-here AZURE_OPENAI_API_KEY=your-azure-key-here AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com
ANTHROPIC_API_KEY=sk-ant-your-key-here AZURE_OPENAI_API_KEY=your-azure-key-here AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com

Optional - Cost tracking

可选 - 成本追踪

GH_AW_ENABLE_COST_TRACKING=true
undefined
GH_AW_ENABLE_COST_TRACKING=true
undefined

Workflow Permissions

工作流权限

Required permissions in workflow YAML:
yaml
permissions:
  contents: write        # To create/update files
  issues: write          # To manage issues
  pull-requests: write   # To manage PRs
  discussions: write     # To manage discussions (if needed)
工作流YAML中需配置的权限:
yaml
permissions:
  contents: write        # 用于创建/更新文件
  issues: write          # 用于管理Issue
  pull-requests: write   # 用于管理PR
  discussions: write     # 用于管理讨论(如有需要)

Common Patterns

常见模式

Command-Triggered Workflows

命令触发工作流

Allow users to trigger agents via comments:
yaml
on:
  issue_comment:
    types: [created]

jobs:
  command-handler:
    if: |
      contains(github.event.comment.body, '/plan') ||
      contains(github.event.comment.body, '/fix')
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/commands.md
允许用户通过评论触发Agent:
yaml
on:
  issue_comment:
    types: [created]

jobs:
  command-handler:
    if: |
      contains(github.event.comment.body, '/plan') ||
      contains(github.event.comment.body, '/fix')
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/commands.md

Scheduled Maintenance

定时维护工作流

Run workflows on a schedule:
yaml
on:
  schedule:
    - cron: '0 0 * * 1'  # Weekly on Monday
    - cron: '0 9 * * *'  # Daily at 9 AM
    - cron: '0 */6 * * *'  # Every 6 hours
按计划运行工作流:
yaml
on:
  schedule:
    - cron: '0 0 * * 1'  # 每周一运行
    - cron: '0 9 * * *'  # 每天上午9点运行
    - cron: '0 */6 * * *'  # 每6小时运行一次

Multi-Stage Workflows

多阶段工作流

Chain multiple agents together:
markdown
undefined
将多个Agent串联起来:
markdown
undefined

Multi-Stage Pipeline

多阶段流水线

Stage 1: Analysis

阶段1:分析

Analyze the repository for issues.
分析仓库中的问题。

Stage 2: Planning

阶段2:规划

Create a plan to address the issues.
创建解决问题的方案。

Stage 3: Execution

阶段3:执行

Implement the plan and create PRs.
实施方案并创建PR。

Stage 4: Verification

阶段4:验证

Verify the changes and update status.
undefined
验证更改并更新状态。
undefined

Conditional Execution

条件执行

markdown
undefined
markdown
undefined

Conditional Agent

条件执行Agent

Pre-Check

预检查

Before proceeding, verify:
  • There are open issues labeled "needs-triage"
  • No other triage workflow is currently running
  • The repository has been active in the last 7 days
If conditions aren't met, exit gracefully.
在执行前,需验证:
  • 存在标记为"needs-triage"的未处理Issue
  • 当前没有其他分类处理工作流在运行
  • 仓库在过去7天内有活跃记录
如果条件不满足,优雅退出。

Main Task

主要任务

[Rest of workflow...]
undefined
[工作流其余部分...]
undefined

Real-World Examples

实际应用示例

Example 1: Bug Fix Automation

示例1:Bug修复自动化

markdown
undefined
markdown
undefined

Bug Fix Agent

Bug修复Agent

Role

角色

You are an experienced developer who investigates and fixes bugs.
你是一名经验丰富的开发者,负责调查并修复Bug。

Workflow

工作流

  1. Identify: Find issues labeled "bug" that haven't been updated in 3 days
  2. Investigate:
    • Read the issue description
    • Check related code files
    • Review recent commits that might be related
    • Look for similar closed issues
  3. Diagnose: Determine the root cause
  4. Fix:
    • Create a branch named
      fix/issue-{number}
    • Implement the fix
    • Write or update tests
    • Commit changes with descriptive message
  5. PR: Create a pull request referencing the issue
  6. Update: Comment on the original issue with findings and PR link
  1. 识别:找到标记为"bug"且3天未更新的Issue
  2. 调查
    • 阅读Issue描述
    • 检查相关代码文件
    • 查看可能相关的近期提交
    • 寻找类似的已关闭Issue
  3. 诊断:确定问题根源
  4. 修复
    • 创建名为
      fix/issue-{number}
      的分支
    • 实现修复方案
    • 编写或更新测试用例
    • 提交带有描述性信息的更改
  5. 创建PR:创建引用该Issue的拉取请求
  6. 更新:在原Issue下评论,说明调查结果和PR链接

Tools

工具

  • github.search.issuesAndPullRequests
    - Find bugs
  • github.repos.getContent
    - Read code files
  • github.git.createRef
    - Create branch
  • github.repos.createOrUpdateFileContents
    - Update files
  • github.pulls.create
    - Create PR
  • github.issues.createComment
    - Update issue
  • github.search.issuesAndPullRequests
    - 查找Bug
  • github.repos.getContent
    - 读取代码文件
  • github.git.createRef
    - 创建分支
  • github.repos.createOrUpdateFileContents
    - 更新文件
  • github.pulls.create
    - 创建PR
  • github.issues.createComment
    - 更新Issue

Quality Standards

质量标准

  • All fixes must include tests
  • Code must follow existing style conventions
  • Commit messages must be descriptive
  • PRs must reference the issue number
undefined
  • 所有修复必须包含测试用例
  • 代码必须遵循现有风格规范
  • 提交信息必须具有描述性
  • PR必须引用Issue编号
undefined

Example 2: Documentation Sync

示例2:文档同步

markdown
undefined
markdown
undefined

Documentation Synchronizer

文档同步器

imports: [shared/formatting.md]
imports: [shared/formatting.md]

Role

角色

Keep documentation in sync with code changes.
保持文档与代码更改同步。

Workflow

工作流

  1. Detect Changes:
    • Find files changed in the last 24 hours
    • Filter for source code files (.js, .py, .go, etc.)
    • Identify public APIs or functions modified
  2. Check Documentation:
    • Locate corresponding documentation files
    • Compare documented behavior with actual code
    • Identify discrepancies
  3. Update Documentation:
    • Create branch
      docs/auto-sync-{date}
    • Update affected documentation files
    • Add examples if new features were added
    • Update any code snippets
  4. Create PR:
    • Title: "docs: sync with code changes from {date}"
    • Body: List all changes with links to commits
    • Request review from code authors
  1. 检测更改
    • 查找过去24小时内更改的文件
    • 筛选源代码文件(.js、.py、.go等)
    • 识别被修改的公共API或函数
  2. 检查文档
    • 定位对应的文档文件
    • 比较文档描述与实际代码行为
    • 识别不一致之处
  3. 更新文档
    • 创建分支
      docs/auto-sync-{date}
    • 更新受影响的文档文件
    • 如果添加了新功能,补充示例
    • 更新所有代码片段
  4. 创建PR
    • 标题:"docs: sync with code changes from {date}"
    • 内容:列出所有更改并附带提交链接
    • 请求代码作者审核

File Mappings

文件映射

  • src/api/*.js
    docs/api/*.md
  • src/cli/*.js
    docs/cli-reference.md
  • lib/*.py
    docs/library-reference.md
  • src/api/*.js
    docs/api/*.md
  • src/cli/*.js
    docs/cli-reference.md
  • lib/*.py
    docs/library-reference.md

Output Format

输出格式

Use the standard formatting from shared/formatting.md
undefined
使用shared/formatting.md中的标准格式
undefined

Example 3: CI Cost Optimizer

示例3:CI成本优化器

markdown
undefined
markdown
undefined

CI Cost Optimizer

CI成本优化器

imports: [shared/reporting.md]
imports: [shared/reporting.md]

Role

角色

Monitor and optimize CI/CD costs.
监控并优化CI/CD成本。

Analysis Tasks

分析任务

  1. Collect Data:
    • Get all workflow runs from the past 7 days
    • Calculate total execution time per workflow
    • Identify slowest steps in each workflow
  2. Identify Waste:
    • Find workflows with high failure rates
    • Detect redundant test runs
    • Spot overly aggressive schedule triggers
    • Find unnecessarily large runners
  3. Generate Report:
    • Calculate estimated costs (if applicable)
    • Create visualization of run times
    • Highlight optimization opportunities
    • Provide specific recommendations
  4. Create Issue:
    • Title: "CI Optimization Report - Week {number}"
    • Include all findings and recommendations
    • Tag with "ci", "optimization", "cost-savings"
  1. 收集数据
    • 获取过去7天内的所有工作流运行记录
    • 计算每个工作流的总执行时间
    • 识别每个工作流中最慢的步骤
  2. 识别浪费
    • 找出失败率高的工作流
    • 检测冗余测试运行
    • 发现过于频繁的定时触发
    • 找出不必要的大型运行器
  3. 生成报告
    • 计算预估成本(如适用)
    • 创建运行时间可视化图表
    • 突出优化机会
    • 提供具体建议
  4. 创建Issue
    • 标题:"CI Optimization Report - Week {number}"
    • 包含所有调查结果和建议
    • 添加标签"ci"、"optimization"、"cost-savings"

Cost Calculations

成本计算

  • Small runner: ~$0.008/minute
  • Medium runner: ~$0.016/minute
  • Large runner: ~$0.032/minute
  • 小型运行器:约$0.008/分钟
  • 中型运行器:约$0.016/分钟
  • 大型运行器:约$0.032/分钟

Optimization Checks

优化检查项

  • Are tests running in parallel where possible?
  • Are caches being used effectively?
  • Are workflows skipping unnecessary runs?
  • Are matrix builds optimized?
  • Are dependencies installed efficiently?
undefined
  • 测试是否尽可能并行运行?
  • 缓存是否有效使用?
  • 工作流是否跳过不必要的运行?
  • 矩阵构建是否优化?
  • 依赖项安装是否高效?
undefined

Troubleshooting

故障排除

Workflow Not Triggering

工作流未触发

Check trigger configuration:
yaml
undefined
检查触发配置:
yaml
undefined

Make sure triggers match your intent

确保触发条件符合你的需求

on: issues: types: [opened, edited] # Not just [opened] pull_request: types: [opened, synchronize] # Include synchronize for new commits
undefined
on: issues: types: [opened, edited] # 不只是[opened] pull_request: types: [opened, synchronize] # 包含synchronize以响应新提交
undefined

Permission Denied Errors

权限拒绝错误

Ensure proper permissions:
yaml
permissions:
  contents: write  # Required for file changes
  issues: write    # Required for issue operations
  pull-requests: write  # Required for PR operations
确保配置了正确的权限:
yaml
permissions:
  contents: write  # 文件更改所需权限
  issues: write    # Issue操作所需权限
  pull-requests: write  # PR操作所需权限

AI Model Timeouts

AI模型超时

Use streaming and set appropriate timeouts:
markdown
undefined
使用流式传输并设置合适的超时时间:
markdown
undefined

Configuration

配置

  • Model: claude-3-5-sonnet-20241022
  • Max tokens: 4000
  • Timeout: 300 seconds
  • Stream: true
undefined
  • Model: claude-3-5-sonnet-20241022
  • Max tokens: 4000
  • Timeout: 300 seconds
  • Stream: true
undefined

Rate Limiting

速率限制

Implement backoff and respect rate limits:
markdown
undefined
实现退避机制并遵守速率限制:
markdown
undefined

Rate Limiting

速率限制

  • Wait 1 second between API calls
  • Use conditional requests (If-None-Match headers)
  • Cache responses when possible
  • Batch operations where supported
undefined
  • API调用之间等待1秒
  • 使用条件请求(If-None-Match头)
  • 尽可能缓存响应
  • 支持批量操作的场景使用批量处理
undefined

Debugging Workflows

工作流调试

Enable debug logging:
yaml
jobs:
  debug:
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/my-workflow.md
          debug: true
        env:
          ACTIONS_STEP_DEBUG: true
启用调试日志:
yaml
jobs:
  debug:
    runs-on: ubuntu-latest
    steps:
      - uses: github/gh-aw@v1
        with:
          workflow: .github/workflows/my-workflow.md
          debug: true
        env:
          ACTIONS_STEP_DEBUG: true

Cost Management

成本管理

Track and limit costs:
markdown
imports: [shared/reporting.md]
追踪并限制成本:
markdown
imports: [shared/reporting.md]

Cost Controls

成本控制

  • Maximum tokens per run: 100,000
  • Alert threshold: $10/day
  • Enable cost tracking in reports
  • Use cheaper models for simple tasks (gpt-4o-mini)
undefined
  • 每次运行的最大令牌数:100,000
  • 警报阈值:$10/天
  • 在报告中启用成本追踪
  • 简单任务使用更便宜的模型(如gpt-4o-mini)
undefined

Best Practices

最佳实践

  1. Start Simple: Begin with basic workflows (issue triage) before complex ones (code generation)
  2. Test Locally: Use
    gh-aw run
    to test workflows before deploying
  3. Monitor Costs: Enable cost tracking and set budgets
  4. Iterate: Refine agent instructions based on actual behavior
  5. Use Shared Fragments: Reuse common patterns from the shared library
  6. Clear Instructions: Write explicit, step-by-step instructions for agents
  7. Error Handling: Include fallback behavior for common failure cases
  8. Human Review: For destructive operations, create PRs instead of direct commits
  1. 从简开始:先从基础工作流(如Issue分类处理)入手,再尝试复杂工作流(如代码生成)
  2. 本地测试:部署前使用
    gh-aw run
    测试工作流
  3. 监控成本:启用成本追踪并设置预算
  4. 迭代优化:根据实际行为完善Agent指令
  5. 使用共享片段:复用共享库中的通用模式
  6. 明确指令:为Agent编写清晰、分步的指令
  7. 错误处理:为常见故障场景添加回退行为
  8. 人工审核:对于破坏性操作,创建PR而非直接提交

Resources

资源