github-agentic-workflows
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub 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
前置条件
- GitHub repository with Actions enabled
- GitHub App or Personal Access Token with appropriate permissions
- Access to an AI model provider (OpenAI, Anthropic, etc.)
- 已启用Actions功能的GitHub代码仓库
- 拥有相应权限的GitHub App或个人访问令牌(Personal Access Token)
- 可访问AI模型提供商(如OpenAI、Anthropic等)
Basic Setup
基础配置
- Install the CLI:
gh-aw
bash
undefined- 安装命令行工具:
gh-aw
bash
undefinedUsing 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- Copy a workflow from the Agentics collection:
bash
undefinedgh extension install github/gh-aw
2. 在代码仓库中创建`.github/workflows`目录:
```bash
mkdir -p .github/workflows- 从Agentics合集中复制工作流:
bash
undefinedExample: Issue Triage workflow
示例:Issue分类处理工作流
curl -o .github/workflows/issue-triage.yml
https://raw.githubusercontent.com/githubnext/agentics/main/.github/workflows/issue-triage.yml
https://raw.githubusercontent.com/githubnext/agentics/main/.github/workflows/issue-triage.yml
curl -o .github/workflows/issue-triage.md
https://raw.githubusercontent.com/githubnext/agentics/main/workflows/issue-triage.md
https://raw.githubusercontent.com/githubnext/agentics/main/workflows/issue-triage.md
4. Configure secrets in your repository settings:
- `GITHUB_TOKEN` (automatically available)
- `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` (for AI model access)curl -o .github/workflows/issue-triage.yml
https://raw.githubusercontent.com/githubnext/agentics/main/.github/workflows/issue-triage.yml
https://raw.githubusercontent.com/githubnext/agentics/main/.github/workflows/issue-triage.yml
curl -o .github/workflows/issue-triage.md
https://raw.githubusercontent.com/githubnext/agentics/main/workflows/issue-triage.md
https://raw.githubusercontent.com/githubnext/agentics/main/workflows/issue-triage.md
4. 在仓库设置中配置密钥:
- `GITHUB_TOKEN`(自动提供)
- `OPENAI_API_KEY`或`ANTHROPIC_API_KEY`(用于访问AI模型)Workflow Structure
工作流结构
Agentic workflows consist of two files:
- YAML file () - GitHub Actions configuration
.github/workflows/*.yml - Markdown file () - Agent instructions and behavior
.github/workflows/*.md
Agentic工作流包含两个文件:
- YAML文件()- GitHub Actions配置文件
.github/workflows/*.yml - Markdown文件()- Agent的指令与行为定义
.github/workflows/*.md
Example: Issue Triage Workflow
示例:Issue分类处理工作流
.github/workflows/issue-triage.ymlyaml
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.mdmarkdown
undefined.github/workflows/issue-triage.ymlyaml
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.mdmarkdown
undefinedIssue Triage Agent
Issue分类处理Agent
You are a helpful issue triage assistant. When a new issue or pull request is opened:
- Read the title and body carefully
- Analyze the content to determine appropriate labels
- Apply relevant labels from the repository's label set
- Add a welcoming comment if this is a first-time contributor
你是一名乐于助人的Issue分类处理助手。当新的Issue或PR创建时:
- 仔细阅读标题和内容
- 分析内容以确定合适的标签
- 从仓库的标签集中选择相关标签添加
- 如果是首次贡献者,添加欢迎评论
Available Tools
可用工具
- - Add labels to issues
github.issues.addLabels - - Comment on issues
github.issues.createComment - - Request reviewers for PRs
github.pulls.requestReviewers
- - 为Issue添加标签
github.issues.addLabels - - 在Issue下评论
github.issues.createComment - - 为PR请求审核人员
github.pulls.requestReviewers
Labels to Consider
可选择的标签
- - Something isn't working
bug - - New feature or request
enhancement - - Documentation improvements
documentation - - Good for newcomers
good first issue - - Extra attention needed
help wanted
- - 功能异常
bug - - 新功能需求
enhancement - - 文档改进
documentation - - 适合新手的任务
good first issue - - 需要额外关注
help wanted
Example Analysis
示例分析
For a bug report mentioning crashes, apply: , potentially
For a feature request, apply:
For documentation fixes, apply: , potentially
bughelp wantedenhancementdocumentationgood first issueundefined对于提到崩溃的Bug报告,添加标签:,可额外添加
对于功能请求,添加标签:
对于文档修复,添加标签:,可额外添加
bughelp wantedenhancementdocumentationgood first issueundefinedKey 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.mdGrumpy 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.mdDocumentation 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.mdDaily 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.mdCustom Workflow Creation
自定义工作流创建
Basic Template
基础模板
markdown
undefinedmarkdown
undefinedMy Custom Agent
我的自定义Agent
Role
角色
You are a [describe the agent's role and purpose].
你是[描述Agent的角色和目标]。
Triggers
触发条件
This workflow runs when [describe trigger conditions].
当[描述触发条件]时,此工作流运行。
Tasks
任务
- [First task description]
- [Second task description]
- [Third task description]
- [第一个任务描述]
- [第二个任务描述]
- [第三个任务描述]
Available Tools
可用工具
List the GitHub API tools you'll use:
- - Create new issues
github.issues.create - - Update files
github.repos.createOrUpdateFileContents - - Create pull requests
github.pulls.create
列出你将使用的GitHub API工具:
- - 创建新Issue
github.issues.create - - 更新文件
github.repos.createOrUpdateFileContents - - 创建PR
github.pulls.create
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链接
- 任何建议
undefinedUsing Shared Fragments
使用共享片段
Import reusable components:
markdown
undefined导入可复用组件:
markdown
undefinedMy 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服务器搜索与[主题]相关的论文。
使用标准格式指南格式化输出。
undefinedAdvanced: MCP Server Integration
进阶:MCP服务器集成
markdown
undefinedmarkdown
undefinedResearch Assistant
研究助手
imports: [shared/arxiv.md, shared/markitdown.md]
imports: [shared/arxiv.md, shared/markitdown.md]
Tasks
任务
- Search arXiv for papers on "machine learning optimization"
- Download the top 3 papers as PDFs
- Convert PDFs to Markdown using MarkItDown
- Summarize findings in an issue
- 在arXiv上搜索关于"machine learning optimization"的论文
- 下载排名前三的论文为PDF格式
- 使用MarkItDown将PDF转换为可读的Markdown
- 在Issue中总结研究结果
MCP Servers
MCP服务器
- arxiv: Search and retrieve academic papers
- markitdown: Convert PDFs to readable Markdown
undefined- arxiv: 搜索并获取学术论文
- markitdown: 将PDF转换为可读的Markdown
undefinedConfiguration
配置
Environment Variables
环境变量
Set in repository secrets or :
.envbash
undefined在仓库密钥或文件中设置:
.envbash
undefinedRequired
必填
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
undefinedGH_AW_ENABLE_COST_TRACKING=true
undefinedWorkflow 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.mdScheduled 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
undefinedMulti-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验证更改并更新状态。
undefinedConditional Execution
条件执行
markdown
undefinedmarkdown
undefinedConditional 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[工作流其余部分...]
undefinedReal-World Examples
实际应用示例
Example 1: Bug Fix Automation
示例1:Bug修复自动化
markdown
undefinedmarkdown
undefinedBug Fix Agent
Bug修复Agent
Role
角色
You are an experienced developer who investigates and fixes bugs.
你是一名经验丰富的开发者,负责调查并修复Bug。
Workflow
工作流
- Identify: Find issues labeled "bug" that haven't been updated in 3 days
- Investigate:
- Read the issue description
- Check related code files
- Review recent commits that might be related
- Look for similar closed issues
- Diagnose: Determine the root cause
- Fix:
- Create a branch named
fix/issue-{number} - Implement the fix
- Write or update tests
- Commit changes with descriptive message
- Create a branch named
- PR: Create a pull request referencing the issue
- Update: Comment on the original issue with findings and PR link
- 识别:找到标记为"bug"且3天未更新的Issue
- 调查:
- 阅读Issue描述
- 检查相关代码文件
- 查看可能相关的近期提交
- 寻找类似的已关闭Issue
- 诊断:确定问题根源
- 修复:
- 创建名为的分支
fix/issue-{number} - 实现修复方案
- 编写或更新测试用例
- 提交带有描述性信息的更改
- 创建名为
- 创建PR:创建引用该Issue的拉取请求
- 更新:在原Issue下评论,说明调查结果和PR链接
Tools
工具
- - Find bugs
github.search.issuesAndPullRequests - - Read code files
github.repos.getContent - - Create branch
github.git.createRef - - Update files
github.repos.createOrUpdateFileContents - - Create PR
github.pulls.create - - Update issue
github.issues.createComment
- - 查找Bug
github.search.issuesAndPullRequests - - 读取代码文件
github.repos.getContent - - 创建分支
github.git.createRef - - 更新文件
github.repos.createOrUpdateFileContents - - 创建PR
github.pulls.create - - 更新Issue
github.issues.createComment
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编号
undefinedExample 2: Documentation Sync
示例2:文档同步
markdown
undefinedmarkdown
undefinedDocumentation Synchronizer
文档同步器
imports: [shared/formatting.md]
imports: [shared/formatting.md]
Role
角色
Keep documentation in sync with code changes.
保持文档与代码更改同步。
Workflow
工作流
-
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
-
Check Documentation:
- Locate corresponding documentation files
- Compare documented behavior with actual code
- Identify discrepancies
-
Update Documentation:
- Create branch
docs/auto-sync-{date} - Update affected documentation files
- Add examples if new features were added
- Update any code snippets
- Create branch
-
Create PR:
- Title: "docs: sync with code changes from {date}"
- Body: List all changes with links to commits
- Request review from code authors
-
检测更改:
- 查找过去24小时内更改的文件
- 筛选源代码文件(.js、.py、.go等)
- 识别被修改的公共API或函数
-
检查文档:
- 定位对应的文档文件
- 比较文档描述与实际代码行为
- 识别不一致之处
-
更新文档:
- 创建分支
docs/auto-sync-{date} - 更新受影响的文档文件
- 如果添加了新功能,补充示例
- 更新所有代码片段
- 创建分支
-
创建PR:
- 标题:"docs: sync with code changes from {date}"
- 内容:列出所有更改并附带提交链接
- 请求代码作者审核
File Mappings
文件映射
- →
src/api/*.jsdocs/api/*.md - →
src/cli/*.jsdocs/cli-reference.md - →
lib/*.pydocs/library-reference.md
- →
src/api/*.jsdocs/api/*.md - →
src/cli/*.jsdocs/cli-reference.md - →
lib/*.pydocs/library-reference.md
Output Format
输出格式
Use the standard formatting from shared/formatting.md
undefined使用shared/formatting.md中的标准格式
undefinedExample 3: CI Cost Optimizer
示例3:CI成本优化器
markdown
undefinedmarkdown
undefinedCI Cost Optimizer
CI成本优化器
imports: [shared/reporting.md]
imports: [shared/reporting.md]
Role
角色
Monitor and optimize CI/CD costs.
监控并优化CI/CD成本。
Analysis Tasks
分析任务
-
Collect Data:
- Get all workflow runs from the past 7 days
- Calculate total execution time per workflow
- Identify slowest steps in each workflow
-
Identify Waste:
- Find workflows with high failure rates
- Detect redundant test runs
- Spot overly aggressive schedule triggers
- Find unnecessarily large runners
-
Generate Report:
- Calculate estimated costs (if applicable)
- Create visualization of run times
- Highlight optimization opportunities
- Provide specific recommendations
-
Create Issue:
- Title: "CI Optimization Report - Week {number}"
- Include all findings and recommendations
- Tag with "ci", "optimization", "cost-savings"
-
收集数据:
- 获取过去7天内的所有工作流运行记录
- 计算每个工作流的总执行时间
- 识别每个工作流中最慢的步骤
-
识别浪费:
- 找出失败率高的工作流
- 检测冗余测试运行
- 发现过于频繁的定时触发
- 找出不必要的大型运行器
-
生成报告:
- 计算预估成本(如适用)
- 创建运行时间可视化图表
- 突出优化机会
- 提供具体建议
-
创建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- 测试是否尽可能并行运行?
- 缓存是否有效使用?
- 工作流是否跳过不必要的运行?
- 矩阵构建是否优化?
- 依赖项安装是否高效?
undefinedTroubleshooting
故障排除
Workflow Not Triggering
工作流未触发
Check trigger configuration:
yaml
undefined检查触发配置:
yaml
undefinedMake sure triggers match your intent
确保触发条件符合你的需求
on:
issues:
types: [opened, edited] # Not just [opened]
pull_request:
types: [opened, synchronize] # Include synchronize for new commits
undefinedon:
issues:
types: [opened, edited] # 不只是[opened]
pull_request:
types: [opened, synchronize] # 包含synchronize以响应新提交
undefinedPermission 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
undefinedConfiguration
配置
- 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
undefinedRate Limiting
速率限制
Implement backoff and respect rate limits:
markdown
undefined实现退避机制并遵守速率限制:
markdown
undefinedRate 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头)
- 尽可能缓存响应
- 支持批量操作的场景使用批量处理
undefinedDebugging 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: trueCost 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)
undefinedBest Practices
最佳实践
- Start Simple: Begin with basic workflows (issue triage) before complex ones (code generation)
- Test Locally: Use to test workflows before deploying
gh-aw run - Monitor Costs: Enable cost tracking and set budgets
- Iterate: Refine agent instructions based on actual behavior
- Use Shared Fragments: Reuse common patterns from the shared library
- Clear Instructions: Write explicit, step-by-step instructions for agents
- Error Handling: Include fallback behavior for common failure cases
- Human Review: For destructive operations, create PRs instead of direct commits
- 从简开始:先从基础工作流(如Issue分类处理)入手,再尝试复杂工作流(如代码生成)
- 本地测试:部署前使用测试工作流
gh-aw run - 监控成本:启用成本追踪并设置预算
- 迭代优化:根据实际行为完善Agent指令
- 使用共享片段:复用共享库中的通用模式
- 明确指令:为Agent编写清晰、分步的指令
- 错误处理:为常见故障场景添加回退行为
- 人工审核:对于破坏性操作,创建PR而非直接提交