Run your own Pydantic AI agent as a GitHub Agentic Workflow
GitHub Agentic Workflows (gh-aw) runs an agent from a
Markdown file in .github/workflows/: it triggers on issues, pull requests or a schedule,
starts the agent in a container behind an egress firewall, hands it MCP tools, and writes
what the agent produces back to GitHub through safe outputs. The
pydantic-ai engine
points that machinery at a Pydantic AI agent, which can be the
Coder composition it runs by default, another agent the harness
ships, or one your own repository defines. The three are laid out in
Start from Coder, Researcher, or your own;
this page then walks through the last of them end to end.
This is the agent running headless: on a GitHub runner, on the events you choose, with nobody at a prompt. Its output is a comment, a pull request or a commit rather than a reply on a screen. The engine records the canonical agent session for inspection, and gh-aw can collect the session and usage artifacts; Observability covers traces.
The agent is your own Agent object, with your instructions, tools,
capabilities, and any model, so the
same agent can also run from the terminal, a web UI, or your own backend.
The finished repository is dsfaccini/gh-aw-pydantic-ai-demo; every file and command below comes from it.
Two pieces of gh-aw vocabulary to set aside first. A gh-aw custom agent (or “agent
file”) is a Markdown prompt in .github/agents/, described under
custom agents; it is
not what this page builds. Here the agent is a Python
Agent object in a module in your repository, named by the
PAI_AGENT environment variable. And engine: driver: is gh-aw’s mechanism for swapping
the inner driver of its copilot engine (and pi on Node); it has no effect on an
import-based engine like this one, so it is not part of the configuration below.
flowchart TB
accTitle: gh-aw: your Pydantic AI agent as a GitHub Agentic Workflow
accDescr: An opened issue triggers the agent job, a container behind an egress firewall, where the pydantic-ai engine starts Pax and runs your Agent named by PAI_AGENT. The agent reaches the model through the api-proxy, which holds the provider key, and calls MCP gateway tools. Its output goes to the threat detection job, then the add-comment job posts the comment with its own token.
issue["issue opened"]:::external
subgraph job["Agent job: container behind egress firewall"]
engine["pydantic-ai engine<br/>starts Pax"]:::capability
agent["your Agent<br/>named by PAI_AGENT"]
end
proxy["api-proxy<br/>holds the<br/>provider key"]:::external
gateway["MCP gateway<br/>github_issue_read,<br/>safeoutputs_add_comment"]:::external
detect["threat<br/>detection job"]:::external
model(["model"])
comment["add-comment job<br/>posts the comment<br/>with its own token"]:::external
issue -->|"triggers"| engine
engine -->|"imports and runs"| agent
agent -->|"placeholder token"| proxy
proxy -->|"model requests"| model
agent <-->|"tool calls"| gateway
agent -->|"output"| detect
detect --> comment
classDef capability stroke:#E520E9,stroke-width:2px
classDef external stroke:#0E9C86,stroke-width:2px
- The
ghCLI, authenticated with therepoandworkflowscopes:gh auth login --scopes repo,workflow. - Use gh-aw v1.0.1 or newer with AWF v0.29.0 or newer. That compiler release defaults to AWF v0.29.0.
- Existing workflows need a compatible runtime build and a newly compiled lockfile.
Installing a newer
gh awCLI locally does not change the runtime an existing lockfile selects. - The protected-capture runtime rejects workflows with
evals, whose secondary engine invocation readsevals.log. Omitevalswhen using this engine. - The workflow summary is the canonical success/failure report. MCP startup and request-limit errors keep their Pax diagnostics and nonzero exit status.
- Linux runners. gh-aw’s sandbox needs Linux and Docker, so the
macos-*andwindows-*runner labels are not supported. - Issues enabled on the repository: the workflow below triggers on the
issuesevent and posts its result as a comment on an issue. gh-aw also checks the setting at compile time when a workflow declares thecreate-issuesafe output, and fails compilation if issues are off. - Actions enabled on the repository (see Repository settings).
Install the current stable compiler, check that it is at least v1.0.1, then compile:
gh extension install github/gh-aw
gh aw version
gh aw compile
For an existing installation, use gh extension upgrade gh-aw before compiling.
For a fresh installation of the exact tested compiler, use
gh extension install github/gh-aw --pin v1.0.1. To upgrade an explicitly pinned
installation, use gh extension upgrade gh-aw --force.
Use Coder by default. Omit PAI_AGENT to use Coder in a
LocalWorkspace on the checkout, with filesystem access and unrestricted
shell commands inside the sandbox. Commands get the step’s environment minus provider
credential variables (OPENAI_*, ANTHROPIC_* and the like). No agent module is needed:
---
on:
issues:
types: [opened]
permissions:
contents: read
issues: read
imports:
- pydantic/pydantic-ai/src/pydantic_ai_harness/gh-aw/pydantic.md@main
engine:
id: pydantic-ai
model: openai/gpt-5
safe-outputs:
add-comment:
---
Another ready-made agent. The harness exports assembled agents as importable variables,
so PAI_AGENT can name one directly and the repository still contains no agent code:
engine:
id: pydantic-ai
model: openai/gpt-5
env:
PAI_AGENT: pydantic_ai_harness.researcher:researcher_agent
steps:
- name: Install the researcher extra
run: python3 -P -m pip install --quiet --user --disable-pip-version-check "pydantic-ai-harness[researcher]"
Researcher needs its own extra for the local search and fetch
fallbacks, which is what the steps: block installs, and its searches need the hosts it
reaches on the workflow’s network: allowlist. pydantic_ai_harness.coder:coder_agent is
the same shape for the coder agent. It differs from the default composition in one way: its
LocalWorkspace passes commands only PATH, HOME and the locale variables, not the step’s
environment.
Your own agent. The rest of this page. Reach for it when the agent needs its own tools,
its own instructions, or a composition the harness does not ship. A harness capability that
reads files or runs commands, such as Coder, needs a workspace: add LocalWorkspace('.')
next to it for the checkout.
my_agent.py at the root of the repository. PAI_AGENT accepts either a module:variable
or dotted MODULE.ATTRIBUTE import target:
"""The agent this repository's agentic workflow runs.
`PAI_AGENT: my_agent:agent` in `.github/workflows/triage.md` names the `agent`
variable below. The engine passes `-m` from the workflow's `engine.model`, so
the model is not set here.
"""
from pydantic_ai import Agent
LABELS = ('bug', 'documentation', 'enhancement', 'question')
agent = Agent(
name='triage',
instructions="""
You triage one GitHub issue. Read the issue in the prompt, then post exactly one
comment with the `safeoutputs_add_comment` tool. The comment has three parts, in order:
1. **Summary.** What the issue reports, in two sentences or fewer.
2. **Suggested label.** One label from `label_catalog()`, and one line saying why.
3. **Question.** What the reporter still needs to tell us before anyone can act.
Write "No follow-up needed." when the issue is already actionable.
Suggest a label; do not apply one. Do not edit files. Do not open issues.
""",
)
@agent.tool_plain
def label_catalog() -> list[str]:
"""The labels this repository triages with."""
return list(LABELS)
- No model. The engine always passes
-mbuilt from the workflow’sengine.model, and an explicit-mreplaces whatever model a loaded agent declares. Setting a model on theAgentwould be ignored, so the workflow is the one place the model is configured. safeoutputs_add_commentis the safe output, not an ordinary tool. gh-aw fronts every MCP server it configures behind a gateway and writes them to${RUNNER_TEMP}/gh-aw/mcp-config/mcp-servers.jsonon the host runner, which the agent step mounts read-only. The engine loads the gateway tools and attaches them through a public dynamic toolset while preserving the agent’s tools, so theadd-commentsafe output arrives assafeoutputs_add_comment. That file is deliberately outside the checkout: a file committed at a path the engine reads would be repository-controlled input to a process holding the gateway’s credentials. The comment itself is posted by a separate job after the agent finishes; the agent never holds a token that can write to the repository.label_catalogis an ordinary function tool. It is here to show that repository code is importable and that the agent’s own tools work alongside the MCP tools gh-aw supplies through the engine’s dynamic toolset.- No third-party imports. The engine installs
pydantic-ai-paxandpydantic-ai-harnessat the release the definition’sengine: version:pins, pluspydantic-ai-slim[anthropic,openai,mcp,spec]>=2.59.0, sopydantic_aiis importable without setup of your own. Anything else your agent imports is installed by a workflow-levelsteps:block (see Dependencies).
The engine resolves and imports the module once, then gives the agent to Pax with
-a, the workflow model with -m, and the prompt with -p. Module-level work therefore
runs once. An import error fails the step with its Python traceback.
PAI_AGENT takes a .yml, .yaml or .json agent spec
wherever it takes an import path, so a repository that is already configuring one thing in
YAML can configure the agent the same way, in a file beside the workflow:
engine:
id: pydantic-ai
model: openai/gpt-5
env:
PAI_AGENT: triage_agent.yml
name: triage
instructions: |
You triage one GitHub issue. Read the issue in the prompt, then post exactly one
comment with the `safeoutputs_add_comment` tool. Suggest a label; do not apply one.
Do not edit files. Do not open issues.
capabilities:
- Thinking:
effort: medium
The engine installs the core spec extra for YAML parsing.
No model: in the spec, for the same reason a module carries none: the engine always
passes -m built from the workflow’s engine.model, and an explicit -m replaces
whatever a loaded agent declares. The workflow is the one place the model is configured.
The engine resolves the spec once and attaches the gateway tools to the resulting agent, so a spec gets safe outputs and GitHub tools on the same terms as a module.
Two things a spec cannot do today, both of which send you back to a module:
- Name a harness capability. A spec resolves capability names through a closed registry
that the harness capabilities are not part of, and the CLI passes no
custom_capability_types, so a spec reaches the built-in capabilities and nothing else.Coder,Researcherand the rest are module-only. See pydantic-ai#8334. - Define a function tool. The
label_catalogtool above is Python, and there is no spec form for it.
Instructions plus built-in capabilities is the shape a spec handles well. Anything past that is a module.
.github/workflows/triage.md:
---
on:
issues:
types: [opened]
permissions:
contents: read
issues: read
imports:
- pydantic/pydantic-ai/src/pydantic_ai_harness/gh-aw/pydantic.md@main
engine:
id: pydantic-ai
model: openai/gpt-5
env:
PAI_AGENT: my_agent:agent
safe-outputs:
add-comment:
---
# Triage the new issue
The issue that triggered this run, as gh-aw sanitized it:
<issue>
${{ steps.sanitized.outputs.text }}
</issue>
Post your triage as a single comment on that issue.
on: issues: types: [opened]is the only trigger.add-commentposts to the issue that triggered the run, and aworkflow_dispatchrun has none, so the workflow declares no manual trigger:gh aw runand the Run workflow button are not part of this walkthrough.permissions:is the workflow-level token scope, and gh-aw rejects a write scope here; the jobs that write to GitHub get their own narrower scopes in the compiled file.issues: readis what lets the GitHub MCP tools read an issue. gh-aw loads a default GitHub read toolset (context,repos,issues,pull_requests,users) with notools:block at all, so the agent hasgithub_issue_readeither way, but without the scope the call comes back403 Resource not accessible by integration. Narrow or widen the toolset withtools: github: toolsets:.imports:pulls in the engine definition. gh-aw’s engine catalog knows thepydantic-aiid but does not import it for you: naming the engine without this line fails to compile.engine: id:selects the imported engine, andengine: model:is required inprovider/modelform. The provider segment selects which backend of gh-aw’s api-proxy serves the request;copilot,anthropic,openaiandcodexare the accepted values. It also decides the wire API:anthropic/runs over the Anthropic Messages API, because that backend forwards the request path toapi.anthropic.comunchanged, and the other three are OpenAI-shaped and use Chat Completions.copilot/runs on Pydantic AI’sgithub-copilot:model, so Copilot’s per-family model profiles apply and the thinking its Claude and Gemini models return inreasoning_textis kept. Its requests carry theagentic-workflowsintegration id, the one the api-proxy adds to requests that carry none. UnderPAI_BASE_URLeverything stays on the generic Chat Completions client.engine: env: PAI_AGENT:is what replaces the engine’s composedCoderagent with yours. The engine writes a private wrapper module in every mode. It appends the checkout tosys.path, after installed packages, only for an imported target whose top-level name nothing installed has, such asmy_agent:agent. A checkout target whose top-level name is also installed resolves against the installed package instead, so it usually fails withModuleNotFoundError.safe-outputs: add-comment:declares the one write this workflow performs. With nosafe-outputs:section at all, gh-aw enablescreate-issuewith a max of 1 instead; declaring the section replaces that default, so the triage does not also open an issue for every issue it comments on.- The body after the frontmatter is the prompt. gh-aw prepends its own context block,
which carries the issue number but not the issue text, so
${{ steps.sanitized.outputs.text }}is what puts the title and body in front of the agent. gh-aw computes that value by sanitizing the triggering item’s content, and it is the form its templating reference documents for prompts (.titleand.bodyexpose the two halves separately).
Freezing the definition. @main is re-resolved on every compile, so a change to the
definition reaches you the next time you run gh aw compile. To hold a fixed version,
import a commit SHA that contains src/pydantic_ai_harness/gh-aw/pydantic.md, or a release
tag cut after the harness moved into this repository; older tags do not carry the file and
return a 404 at compile time. That ref pins the definition. The harness package version
is pinned separately, by engine: version: in the definition, and a workflow’s own
engine: version: overrides it. An override has to be 0.73.0 or newer: the definition
installs pydantic-ai-pax at the same version, and 0.73.0 is its first release. Each
harness release also pins its own pydantic-ai-slim, and the definition installs
pydantic-ai-slim>=2.59.0 alongside it.
gh aw compile
The compiler writes:
.github/workflows/triage.lock.yml, the GitHub Actions workflow that actually runs..github/aw/actions-lock.json, the SHA pins for every action the lock uses..github/aw/imports/pydantic/pydantic-ai/<sha>/src_pydantic_ai_harness_gh-aw_pydantic.md, a byte-identical cache of the imported definition at the resolved SHA..github/aw/imports/.gitattributesand a top-level.gitattributesmarking generated files.
Commit all of it, together with the .md. The compiled workflow’s Check workflow lock file step recomputes the frontmatter hash at run time and fails the run when the lock does
not match the source, so a stale or missing lock stops the workflow rather than running an
old configuration.
Every compile prints Using experimental engine: Pydantic AI. The engine definition
declares itself experimental to gh-aw, which is a statement about this definition’s
interface with gh-aw rather than about Pydantic AI: the two projects are moving, and the
definition is free to change how it bridges them. Pin the imports: ref to a tag or a SHA
when that matters, as described above.
Compiling this workflow for the first time prints a security-review warning listing
CODEX_API_KEY and OPENAI_API_KEY as new restricted secrets. gh-aw records the secrets,
actions and container images a lock uses in a gh-aw-manifest header and asks you to look
at additions before it accepts them. Read the list, then re-run with --approve:
gh aw compile --approve
gh aw compile also caches the remote import under .github/aw/imports/ by commit SHA.
gh-aw treats the lock and that cache together as the
reproducibility guarantee
for shared workflows, so commit it alongside the .md and the .lock.yml.
Anything your agent imports beyond the engine’s runtime dependencies is installed by a
workflow-level steps: block:
steps:
- name: Install the agent's dependencies
run: python3 -P -m pip install --quiet --user --disable-pip-version-check httpx
--user installs into $HOME/.local, which is the directory the sandbox exposes and the
one the engine’s own install already uses; a system-wide install would land somewhere the
agent cannot read. -P keeps the checkout off sys.path for the install itself, so a
module in your repository named after a package cannot be imported in place of the real
one.
Order matters, and the compiled lock puts these steps in the right place. In the generated
workflow, Setup Python runs before your steps:, then the engine’s install and agent
steps. Your install therefore runs against the same interpreter the engine later uses.
A step can also end a run that has nothing to do by appending
{"type":"noop","message":"..."} to $GH_AW_SAFE_OUTPUTS. The engine reads that file
before it starts Pax and exits with status 0 when it finds a noop, so no model request
is made. gh-aw’s
cost management reference
documents the pattern. When a search query can express the condition, skip-if-match or
skip-if-no-match also avoids scheduling the agent job.
The provider segment of engine.model decides which repository secret the agent step
reads:
engine.model prefix | Secret |
|---|---|
copilot/... | COPILOT_GITHUB_TOKEN |
anthropic/... | ANTHROPIC_API_KEY |
openai/... | CODEX_API_KEY, or OPENAI_API_KEY when CODEX_API_KEY is unset |
codex/... | CODEX_API_KEY, or OPENAI_API_KEY when CODEX_API_KEY is unset |
Only the secret for the provider you use needs setting, plus whichever one
threat detection reads. The workflow above uses
openai/gpt-5, so it needs CODEX_API_KEY or, when that is unset, OPENAI_API_KEY, plus
COPILOT_GITHUB_TOKEN for threat detection unless it adds the codex override shown there.
The examples below set OPENAI_API_KEY.
gh aw secrets set OPENAI_API_KEY --value "<key>"
The value can also come from an environment variable
(--value-from-env OPENAI_KEY) or from stdin, and --repo owner/name targets a
repository other than the current one. gh aw secrets bootstrap reads the compiled
workflows and walks you through whatever is missing. Plain gh secret set OPENAI_API_KEY works too; it prompts for the value or reads it from stdin.
Settings -> Secrets and variables -> Actions -> New repository secret. Name it
OPENAI_API_KEY and paste the key. GitHub documents the screen under
using secrets in GitHub Actions.
Where the key comes from, per provider:
- OpenAI and Codex: https://platform.openai.com/api-keys.
- Anthropic: https://console.anthropic.com/settings/keys.
- Copilot: a fine-grained PAT from
https://github.com/settings/personal-access-tokens/new with the resource owner set to
your account and Account permissions -> Copilot Requests set to Read.
gho_OAuth tokens are rejected. With an organization Copilot subscription on centralized billing you can skip the PAT and addpermissions: copilot-requests: writeinstead, which makes the agent step use the run’sgithub.token.
There is no PAI_API_KEY. gh-aw keeps repository secrets out of the agent sandbox: any
engine.env value containing ${{ secrets.* }} is stripped from the agent’s environment
via awf --exclude-env, and the compiler fails the workflow rather than let you assume
otherwise. The provider credential lives in gh-aw’s api-proxy, on the other side of the
sandbox boundary, and the agent sends a placeholder bearer token it cannot leak. To reach a
keyed endpoint of your own, point PAI_BASE_URL at a gateway you run that holds the key;
the engine’s
README
covers that path.
With safe outputs declared, gh-aw runs a
threat-detection job over the
agent’s output before applying it. That job runs only on gh-aw’s built-in engines, and the
definition picks copilot, so detection reads COPILOT_GITHUB_TOKEN, or the run’s
github.token under permissions: copilot-requests: write, even when the agent uses
another provider. A workflow with neither points detection at the built-in engine whose
key it already has, codex for openai/ and codex/ models and claude for
anthropic/ ones, or sets false to skip the AI analysis. The workflow above has an
OpenAI key, so it would add:
safe-outputs:
add-comment:
threat-detection:
engine: codex
Actions enabled.
gh api repos/OWNER/REPO/actions/permissions
gh api -X PUT repos/OWNER/REPO/actions/permissions -F enabled=true -f allowed_actions=all
The PUT sets the whole policy, so send allowed_actions with the value you want
rather than relying on the current one being kept.
Settings -> Actions -> General -> Actions permissions. GitHub’s guide describes the screen.
Allowed actions. Only relevant when allowed_actions is selected. The compiled lock
uses actions from two owners: actions/* (checkout, setup-python, setup-node,
cache, github-script, upload-artifact, download-artifact) and
github/gh-aw-actions/*. Both need to be in the allowlist. gh-aw’s own troubleshooting
page still lists github/gh-aw@*, which is not what current versions emit.
gh api repos/OWNER/REPO/actions/permissions/selected-actions
gh api -X PUT repos/OWNER/REPO/actions/permissions/selected-actions \
-F github_owned_allowed=true \
-f 'patterns_allowed[]=github/gh-aw-actions/*'
github_owned_allowed covers the actions/* half. The selected-actions endpoint
only applies while allowed_actions is selected.
Settings -> Actions -> General -> Allow select actions -> Allow specified actions and reusable workflows.
Default-branch placement. GitHub only fires the issues event for workflow files on
the repository’s default branch. Nothing happens while the workflow sits on a feature branch; this is
GitHub Actions behavior,
not a gh-aw setting, and gh-aw’s own pages do not mention it.
Who may trigger. The compiled workflow gates on the triggering user’s repository role,
defaulting to admin, maintainer and write. An issue opened by someone outside that
set does not start the agent. Widen or narrow it with the roles: frontmatter key.
Forks. gh-aw blocks pull requests from forks unless the pull_request trigger names
them in a forks: allowlist, and documents that agentic workflows do not run inside a
forked copy of a repository. See
fork support.
Repository-level “Read and write permissions” for the default GITHUB_TOKEN is not needed:
the lock declares its scopes per job. “Allow GitHub Actions to create and approve pull
requests” only matters for the create-pull-request safe output.
Merge the workflow to the default branch. Opening an issue then starts a run.
gh aw status
gh aw status lists each workflow with its engine, whether the lock is current, and
whether the workflow is enabled:
╭────────┬───────────┬────────┬──────┬─────────┬──────┬──────┬──────────╮
│workflow│engine │compiled│state │remaining│run id│status│conclusion│
├────────┼───────────┼────────┼──────┼─────────┼──────┼──────┼──────────┤
│triage │pydantic-ai│Yes │active│N/A │0 │- │- │
╰────────┴───────────┴────────┴──────┴─────────┴──────┴──────┴──────────╯
After a run:
gh aw logs triage --artifacts all
gh aw audit <run-id-or-url>
gh aw logs downloads runs into per-run folders; --artifacts all adds the agent logs,
agent-stdio.log, aw.patch and summary.json to the compact usage artifact it fetches
by default. gh aw audit turns one run into a Markdown report under .github/aw/logs, and
diffs two or more runs when given more than one id. For the raw step output, including the
engine’s own lines, gh run view <run-id> --log (add --attempt N for an earlier attempt)
is often quicker.
The engine records assistant messages, reasoning, tool calls and results, and usage from a host-protected capture. Ordinary terminal output and files written by agent tools cannot supply canonical session records.
The canonical stream in agent-session.jsonl includes session.init, user.message,
assistant.message, assistant.reasoning, tool.execution_start,
tool.execution_complete, and session.result. The result includes reported usage when
available; startup failures still record status without usage when none is available.
If finalizing the recording fails, the launcher reports the error as terminal output,
preserves the CLI exit status, and attempts a status-only result.
A recording is published only after its authenticity, sequence, and terminal result are
verified. A missing session.result, authenticated sequence gap, or authenticated event
after the terminal leaves the authenticated prefix in separate parser diagnostics,
without canonical status or usage. Complete failure recordings retain observed partial
content and their failure result. An abrupt SIGTERM or SIGKILL can prevent a terminal
result; such recordings remain diagnostic-only, including timeout or cancellation cases.
No tool IDs, completions, or turns are inferred.
gh-aw redacts configured secrets and MCP gateway bearer tokens from session artifacts.
The engine parser treats runtime ::add-mask:: commands as data. gh-aw applies masks
from captured output when publishing artifacts, rejecting masks that would change
event structure, status, or usage.
The agent step starts pax -a <target> -m <provider:model> -p <prompt> with the
generated Coder agent or the PAI_AGENT target resolved by the engine. The engine
starts Pax with PYTHON_DOTENV_DISABLED=1, so a .env file in the checkout is not
loaded; set the run’s variables with engine.env. The recorder
captures assistant messages, reasoning, tool calls and results (including native tools),
and usage. Repository Python imported through
PAI_AGENT and any caller-supplied PYTHONPATH are trusted engine configuration.
Python can import from PYTHONPATH before the recorder starts, and PAI_AGENT runs in
the recorder interpreter. Point either setting only at code you trust.
The gh-aw conclusion step gathers the agent session and usage into aw_session.jsonl and
includes gateway and safe-output activity; download it with the gh aw logs command above.
The comment lands on the issue with a gh-aw footer naming the workflow and linking its run, followed by an HTML comment recording the engine, its version and the model.
gh-aw keeps OTLP endpoints and authorization headers on the host, so the agent sandbox
receives no telemetry credentials. Host and proxy telemetry use gh-aw’s own exporters,
configured with observability.otlp.
When OTEL_EXPORTER_OTLP_ENDPOINT reaches the launcher, it instruments Pydantic AI and
exports spans directly, with send_to_logfire='if-token-present'. gh-aw excludes that
variable from the agent container, so this direct export does not run under gh-aw. The
launcher attaches TRACEPARENT and preserves OTEL_RESOURCE_ATTRIBUTES, so exported
spans keep their workflow parentage and identity.
When it configures Logfire, the launcher uses private mode-0700 configuration and data
directories under /tmp, ignoring checkout settings and credentials. console=False
prevents span content entering captured engine stdio.
A PAI_AGENT module can add HTTP or MCP instrumentation after the launcher configures
Logfire. Calling logfire.configure() again replaces that configuration. Preserve the
private directories, disabled console output and distributed tracing if the agent replaces it.
Set PAI_RESULT_METADATA to MODULE:ATTRIBUTE to include a trusted agent module’s
dictionary in session.result.data.metadata. The dictionary must have string keys
and JSON-serializable values. Update the same dictionary during the run; the recorder
serializes it when the process finishes, including handled failures. A target that is
not such a dictionary fails the run. Metadata that cannot be serialized is left out,
and the result still records the run’s outcome.
The engine signs this metadata with the terminal result. Ordinary stdout and
sandbox-written files cannot substitute for it. Consumers should read the verified
agent-session.jsonl artifact and validate their metadata schema and run identity.
Like PAI_AGENT, this import target is trusted engine configuration.
error: invalid engine: pydantic-ai. Valid engines are: claude, codex, copilot, gemini, pi. The imports: line is missing. Add
pydantic/pydantic-ai/src/pydantic_ai_harness/gh-aw/pydantic.md@main.
error: invalid engine.model for engine 'pydantic-ai': for universal consumer engines, engine.model must use provider/model format The provider/ prefix is missing from
engine.model. gh-aw checks this before the engine runs.
error: strict mode: secrets detected in 'engine.env' section are excluded from the agent sandbox via awf --exclude-env A $\{\{ secrets.* \}\} reference is in engine.env. It
would have been stripped from the agent’s environment anyway; set the provider’s secret as
a repository secret instead.
warning: safe update mode detected unapproved changes with a list of new restricted
secrets. Expected on the first compile, and on any compile that changes which secrets,
actions or images the lock uses. Review the list, then re-run gh aw compile --approve.
[INFO] API proxy enabled: OpenAI=false, Anthropic=false, ... then
health-check Cannot connect to OpenAI API proxy at http://host.docker.internal:10000.
The provider secret is missing or empty, so gh-aw starts no proxy backend and the job fails
before the engine’s own script runs. The preceding line says so directly:
[WARN] API proxy enabled but no API keys found in environment. Set the secret, then rerun
the run with gh run rerun <run-id> so secrets are read again. A run that started before
the secret existed keeps the empty value for its whole life, so re-running the same attempt
is the fix, not waiting.
Lock file '...' is outdated! The workflow file '...' frontmatter has changed. Run 'gh aw compile' to regenerate the lock file. The committed .lock.yml does not match the
.md. Recompile and commit the result.
The workflow never starts when an issue is opened. Check that the workflow file is on
the default branch, and that the account that opened the issue has one of the roles in
roles:.
A coding agent with shell access can do this setup end to end: it writes both files, and
gh aw compile reports precisely what is wrong with the frontmatter when it gets one
wrong. Give it this page and the module:variable of the agent you want run.
Read https://pydantic.dev/docs/ai/harness/gh-aw/ and set up a gh-aw agentic workflow in
this repository that runs my Pydantic AI agent at my_agent:agent on newly opened issues.
The finished repository for this walkthrough is
dsfaccini/gh-aw-pydantic-ai-demo.
The engine’s own reference documentation, covering the default coder agent, custom
endpoints and the credential model, is the
gh-aw/README.md
in this repository.