Learning resourcesReviewed · Pydantic

Run your own Pydantic AI agent as a GitHub Agentic Workflow

This guide shows Python developers how to run Pydantic AI agents on GitHub events, but the bridge to GitHub Agentic Workflows is experimental. It explains agent configuration, issue triage, compiled workflow files, provider credentials, controlled GitHub writes and session records.

Researched 25 Nov 2026

In short.

This tutorial teaches developers to run Pydantic AI agents on GitHub events, but its experimental integration requires compatible tooling and careful repository configuration. Its worked example loads a Python Agent, reads a newly opened issue and requests one comment through GitHub Agentic Workflows. The page explains Linux runner requirements, generated workflow files, credentials held outside the agent sandbox, separate jobs for GitHub writes and recorded agent sessions. The examples were not executed; operational reliability, security effectiveness, output quality and total cost remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is the complete documentation page at [https://pydantic.dev/docs/ai/harness/gh-aw/index.md], including its opening documentation-index and agent-query notices, examples, prerequisites, observability details and troubleshooting. Those opening notices concern documentation navigation and add no execution evidence. Linked documentation, repositories, releases, issue discussions, provider pages and licence files are excluded. No commands, compilation, model calls or GitHub workflows were executed. Compatibility, output quality, isolation, credential protection, session authenticity and GitHub writes were not independently tested.

The overview

Identity

This is a Pydantic documentation tutorial at [https://pydantic.dev/docs/ai/harness/gh-aw/index.md]. It explains the pydantic-ai engine that connects a Pydantic AI Agent to GitHub Agentic Workflows, commonly called gh-aw.

The agent runs without an interactive prompt on a GitHub runner. Its results can become GitHub comments, pull requests or commits through configured safe outputs. The walkthrough builds an issue-comment workflow using a Python Agent object identified by PAI_AGENT.

Assessment

The guide is useful for developers who want to reuse an existing Pydantic AI agent in repository automation. It supplies connected Python and workflow examples, explains why particular permissions and dependencies are needed, and addresses failures such as missing credentials, outdated lockfiles and workflows that never start.

Its main adoption constraint is the experimental interface between the engine definition and gh-aw. The documentation gives a detailed implementation recipe, but it does not establish production reliability or the quality of automated triage. The experimental designation applies to this bridge, rather than to Pydantic AI as a whole.

Users

The clearest audience is Python developers and repository maintainers automating tasks such as issue triage or coding work. A custom agent is particularly relevant when the task needs repository-specific tools, instructions or capabilities.

Beginners receive complete example files, but still need familiarity with Python imports, GitHub Actions, command-line tools and repository secrets. Developers who already use Pydantic AI can retain their Agent definition while moving execution to GitHub events.

Capabilities

The integration supports event-driven, unattended agents with their own instructions and tools, alongside MCP tools supplied by gh-aw. The wider workflow system supports issue, pull-request and scheduled triggers; this walkthrough uses newly opened issues and a single add-comment safe output.

Omitting PAI_AGENT selects the composed Coder agent, which has checkout filesystem access and unrestricted shell commands inside the sandbox. PAI_AGENT can instead select Researcher, another importable agent, a repository-defined Python Agent or a YAML/JSON agent specification. Researcher requires an additional package extra and network access to its search destinations.

The engine records assistant messages, reasoning, tool calls, results and reported usage. It also supports trusted terminal metadata through PAI_RESULT_METADATA, whose target must be a dictionary with string keys and JSON-serializable values. The page describes host-side telemetry and optional agent instrumentation, without reporting measured observability performance.

Using it

Requirements

The page requires an authenticated gh CLI with repo and workflow scopes, gh-aw v1.0.1 or newer, and an AWF runtime v0.29.0 or newer. Execution requires Linux and Docker. Existing compiled workflows need a compatible runtime build and a newly compiled lockfile; upgrading the local CLI alone does not update their runtime.

The issue-triage example requires repository Issues and Actions to be enabled, appropriate allowed-action settings, read permissions for contents and issues, and credentials for the selected model provider. Threat detection may require a separate provider credential.

The engine installs its Python runtime dependencies, including pydantic-ai-slim[anthropic,openai,mcp,spec]>=2.59.0. Additional packages imported by a custom agent need a workflow installation step. Capabilities that read files or run commands need an appropriate workspace, such as LocalWorkspace('.').

Mechanism

gh-aw compiles a Markdown workflow into a GitHub Actions lockfile. The imported pydantic-ai engine resolves the agent and launches Pax with the agent, model and workflow prompt. PAI_AGENT accepts module:variable, a dotted import target or a supported specification file. The workflow's engine.model overrides any model declared by the loaded agent.

The agent runs in a container behind an outbound-network firewall. Provider credentials stay in gh-aw's external API proxy, while the agent sends a placeholder bearer token. The engine attaches gateway-provided MCP tools alongside the agent's own tools. Requested safe outputs pass through threat detection before a separate job performs the GitHub write using its own token.

Session records come from host-protected capture. The page says publication of a canonical recording requires verification of its authenticity, sequence and terminal result. Ordinary tool output and sandbox-written files cannot supply replacement canonical records. These are documented mechanisms; their security properties were not independently verified.

Setup

Install or upgrade the gh-aw extension and check its version. For a custom Python agent, create my_agent.py and a Markdown workflow such as .github/workflows/triage.md. The workflow imports pydantic/pydantic-ai/src/pydantic_ai_harness/gh-aw/pydantic.md, selects engine id pydantic-ai, sets a provider/model value, identifies my_agent:agent through PAI_AGENT and declares add-comment.

Store the chosen provider credential as a repository secret. In the OpenAI example, the engine uses CODEX_API_KEY, falling back to OPENAI_API_KEY when the former is unset. Threat detection defaults to Copilot; the example can explicitly select the codex detection engine to use its available OpenAI credential. Secret references placed in engine.env are rejected by the compiler.

Compile with gh aw compile, review any newly introduced secrets, actions and images, and use gh aw compile --approve when accepting those changes. Commit the Markdown source, generated lockfile, action pins, cached import and generated attributes. Additional Python packages are installed with workflow steps using the same interpreter and the sandbox-visible user installation directory.

Example

The worked agent triages one newly opened issue. Its label_catalog function returns bug, documentation, enhancement and question. The instructions request exactly one comment containing a short summary, a suggested label with a reason, and a follow-up question or the statement that no follow-up is needed. They prohibit applying labels, editing files and opening issues.

The workflow uses openai/gpt-5, PAI_AGENT set to my_agent:agent, read permissions for contents and issues, and the add-comment safe output. Its prompt includes the triggering issue's sanitized title and body through steps.sanitized.outputs.text; gh-aw's automatically prepended context alone does not include the issue text.

The documented expected result is a comment on the triggering issue with a workflow footer and run link. The page points to [https://github.com/dsfaccini/gh-aw-pydantic-ai-demo] as the completed example repository. Neither that repository nor the example's behavior was independently examined or executed.

Assessment & evidence

Limitations

The integration is experimental and supports Linux runners. The protected-capture runtime rejects workflows using evals. Agent specifications support instructions and built-in capabilities, but cannot define Python function tools or name harness capabilities such as Coder and Researcher.

The bridge accepts copilot, anthropic, openai and codex model-provider prefixes. Anthropic uses the Messages API; the other prefixes use Chat Completions. A PAI_BASE_URL override uses the generic Chat Completions client. Custom keyed endpoints require an external gateway holding the key; the engine has no PAI_API_KEY setting.

For the issue example, the workflow must be on the default branch. Triggering roles default to admin, maintainer and write, so issues opened by other users do not start it unless roles are changed. The walkthrough has no manual trigger. Fork execution is restricted, and fork pull requests require an explicit allowlist.

Trusted Python configuration remains consequential: PAI_AGENT code runs in the recorder interpreter, and supplied PYTHONPATH entries can load code before recording starts. Installed packages also take precedence over a checkout module with the same top-level name. Abrupt termination can leave session records diagnostic-only when no terminal result is captured.

Reasoning

The integration's practical value is reuse: developers can keep their Pydantic AI instructions and tools while gh-aw supplies triggers, isolation, GitHub access and output handling. That is a concrete fit for teams with an existing Agent or a need for Python-defined repository tools.

Workflow read permissions and local agent capabilities address different things. The default Coder can modify the checkout and run shell commands inside its sandbox even when the workflow's GitHub permissions are read-only. Choosing the agent's capabilities and choosing its allowed published outputs are therefore separate configuration decisions.

Alternatives

The page presents several choices within this integration. Default Coder supplies filesystem and shell capabilities without repository agent code. Researcher supplies a ready-made research composition with additional installation and network requirements. A custom Python module supports repository-specific function tools and capabilities. A YAML or JSON specification suits instructions plus built-in capabilities.

It also notes that the same Agent can run from a terminal, web UI or backend. The supplied page does not explain those deployment paths or compare this integration's cost, quality or reliability with other automation products.

Evidence

The evidence is the complete documentation text acquired from [https://pydantic.dev/docs/ai/harness/gh-aw/index.md]. It includes Python and YAML examples, compilation instructions, sample status output, architecture explanations and troubleshooting guidance.

The page links to engine source at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/gh-aw] and to a completed demo repository. Those linked contents were not included. Displayed commands and outputs are documentation examples, rather than independently reproduced results. No benchmark, independent security audit or comparative output-quality evaluation is supplied.

Access & freshness

Costs

The page provides no prices, representative token consumption, runner charges or per-run estimates. Total cost is unknown. Potential cost drivers include agent model requests, the separate threat-detection model invocation and GitHub Actions execution, depending on the accounts and services used.

Usage artifacts can report available model usage. The page also describes a noop mechanism that ends a run before a model request, plus skip-if-match and skip-if-no-match conditions that can avoid scheduling the agent job. No measured savings are supplied.

Rights

The supplied page does not state licence terms for its documentation, embedded code examples, imported engine or linked demo. Reuse and redistribution permissions for those materials are not established by this evidence. Licence files in linked repositories are outside the supplied page.

Freshness

The documentation was captured on 25 November 2026 at 20:39:44.498 UTC. The supplied text does not establish its publication or last-update date. Its stated version minimums describe that capture; current compatibility beyond it is unknown.

Imports using @main are resolved again on every compilation. A suitable commit SHA or release tag fixes the engine definition, while engine.version separately fixes the harness package version. The page requires explicit harness overrides to be 0.59.0 or newer and warns that older repository tags may lack the imported definition. Recompilation and committed generated files are necessary when updating the workflow.

Actions

Choose the agent form that matches the task, then confirm the compiler, runtime, Linux runner, repository settings and credentials meet the documented requirements. For a custom agent, use trusted import code and install its additional dependencies. Pin the imported definition when repeatable configuration matters.

For an initial deployment, follow the narrow issue-comment example, explicitly configure threat detection, compile and commit all generated files, and place the workflow on the default branch. Open an issue from an allowed account to check the intended trigger.

Inspect the workflow summary for success or failure. Use gh aw logs triage --artifacts all and gh aw audit with a run identifier to inspect artifacts and activity. Check the actual comment and canonical session result before relying on the automation. These are suggested adoption checks; no such run was performed.

Evidence for this report

selected-page.txtselected · checked 2026-11-25