Skip to content

Add Pydantic AI shared engine definition and smoke test - #51161

Merged
pelikhan merged 8 commits into
mainfrom
copilot/pydantic-ai-agentic-engine
Aug 7, 2026
Merged

Add Pydantic AI shared engine definition and smoke test#51161
pelikhan merged 8 commits into
mainfrom
copilot/pydantic-ai-agentic-engine

Conversation

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Pydantic AI wants to dogfood their own stack as a gh-aw engine. This adds the shared definition and smoke test to support engine: id: pydantic-ai as a first-class importable engine.

shared/pydantic.md

Shared engine definition following the aider.md pre-agent-steps pattern (used because behaviors.installation.package-manager: uv silently emits no install step):

engine:
  id: pydantic-ai
model: copilot/claude-sonnet-4-5
imports:
  - shared/pydantic.md
  • Installs pydantic-ai-harness via pip in pre-agent-steps; version pinned via engine.version
  • secret-strategy: universal-llm-consumer — routes through AWF proxy
  • MCP enabled; reads server config from GH_AW_MCP_CONFIG so safe outputs flow through safeoutputs automatically
  • Includes a log-parser function that normalizes Pydantic AI JSONL output into conversation events, enabling step summaries and token tracking in gh aw logs / gh aw audit

smoke-pydantic.md

Smoke test workflow mirroring smoke-aider.md: validates file writing, bash execution, and repo access, then emits results as an issue + PR comment via $GH_AW_SAFE_OUTPUTS.


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.54 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Copilot AI linked an issue Aug 7, 2026 that may be closed by this pull request
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Pydantic AI as an agentic engine Add Pydantic AI shared engine definition and smoke test Aug 7, 2026
@pelikhan
pelikhan marked this pull request as ready for review August 7, 2026 19:13
Copilot AI balanced review requested due to automatic review settings August 7, 2026 19:13
@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot add pydantic-ai to engines.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a first-class Pydantic AI engine definition and smoke workflow.

Changes:

  • Defines installation, execution, MCP, networking, and log parsing.
  • Adds a smoke workflow and slash-command routing.
  • Generates the corresponding workflow lock file.
Show a summary per file
File Description
.github/workflows/shared/pydantic.md Defines the Pydantic AI engine.
.github/workflows/smoke-pydantic.md Adds engine smoke testing.
.github/workflows/smoke-pydantic.lock.yml Compiles the smoke workflow.
.github/workflows/agentic_commands.yml Registers /smoke-pydantic.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +60 to +62
1. **File Writing Testing**: Create a test file `/tmp/gh-aw/agent/smoke-test-pydantic-${{ github.run_id }}.txt` with content "Smoke test passed for Pydantic AI" (create the directory if it doesn't exist)
2. **Bash Tool Testing**: Execute bash commands to verify file creation was successful (use `cat` to read the file back)
3. **Repository Access Testing**: Run `git log --oneline -1` in the repository checkout and confirm a commit is reported
- .pydantic-ai/
network:
defaults:
- host.docker.internal

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot none of these should be needed since pydantic is already pre-installed. keep network as "defaults"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in d36df30. I removed the Pydantic install pre-step and switched the shared engine networking back to defaults (dropping the extra PyPI domains).

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Test Quality Sentinel. Review the logs for details.

No test files were added or modified in this PR. Test Quality Sentinel skipped. PR contains only workflow definitions (.md, .yml, .lock.yml) and no behavioral tests (Go *_test.go or JavaScript .test.cjs/.test.js).

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Design Decision Gate 🏗️. Review the logs for details.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (0 additions detected in default business logic paths).

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security scanning failed for Matt Pocock Skills Reviewer. Review the logs for details.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add pydantic-ai to engines.json

Added in 4d4987c: .github/aw/engines.json now includes pydantic-ai mapped to github/gh-aw/.github/workflows/shared/pydantic.md.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /codebase-design and /tdd — commenting (no blocking issues, but a few items worth addressing before promoting from experimental).

📋 Key Themes & Highlights

Key Themes

  • Runtime network policy: smoke-pydantic.md sets network: allowed: [] which may conflict with the engine's need to reach the LLM proxy. Needs verification against smoke-aider.md baseline.
  • Log-parser token extraction: Silent zero-token totals when Pydantic AI emits usage under a nested key (e.g. usage.input_tokens). A small fixture-based test would prevent regressions.
  • Empty tool_result content: msg can be empty string; downstream schema validators may reject it.
  • Network hosts at runtime vs install-time: PyPI entries in the runtime allowlist are only needed during pre-agent-steps.
  • Version override discoverability: Override pattern documented only in an HTML comment; a YAML-adjacent comment would be more visible.

Positive Highlights

  • ✅ Clean log-parser structure mirroring the aider pattern
  • secret-strategy: universal-llm-consumer correctly routes through AWF proxy
  • ✅ MCP config via GH_AW_MCP_CONFIG is consistent with the existing engine contract
  • ✅ Smoke test structure mirrors smoke-aider.md — easy to compare and audit

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 38.3 AIC · ⊞ 7.1K
Comment /matt to run again

- .pydantic-ai/
network:
defaults:
- host.docker.internal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] Network defaults includes pypi.org and files.pythonhosted.org — these are only needed during pre-agent-steps installation, not agent runtime.

💡 Suggestion

PyPI hosts are consumed by pip install in pre-agent-steps, which runs before the agent sandbox. If the runtime network policy cannot be scoped per-phase, document why these hosts must remain open during agent execution. Also, the PR comment from @pelikhan suggests pydantic-ai-harness may already be pre-installed, which would make the pip install step and these entries unnecessary entirely.

@copilot please address this.

if (parsed.input_tokens) inputTokens += parsed.input_tokens;
if (parsed.output_tokens) outputTokens += parsed.output_tokens;
const entryType = parsed.type != null ? String(parsed.type) : "log";
const msg = parsed.msg || parsed.message || parsed.content || "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The log-parser only accumulates input_tokens / output_tokens from JSON lines that have those exact keys — if Pydantic AI emits them under a different key (e.g. usage.input_tokens) the totals silently remain zero.

💡 Suggestion

Add a test fixture (a small JSONL sample) and a unit test that asserts:

  • known token-bearing lines are counted correctly
  • lines with a nested usage object are also handled
  • the final result entry reflects the correct totals

Without this, a Pydantic AI output format change will produce invisible zero-token audit entries.

@copilot please address this.

const toolName = parsed.tool || parsed.name || entryType;
logEntries.push({ type: "assistant", message: { content: [{ type: "tool_use", id: toolId, name: toolName, input: {} }] } });
logEntries.push({ type: "user", message: { content: [{ type: "tool_result", tool_use_id: toolId, content: msg }] } });
} else if (msg) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] Tool-result entries always set content: msg where msg may be an empty string — the harness may reject a tool_result with an empty content array.

💡 Suggestion

Use a fallback: content: msg || '(no output)' to guarantee a non-empty string. Downstream log consumers that validate against the Anthropic message schema will reject empty content.

@copilot please address this.

id: pydantic-ai
strict: true
imports:
- shared/pydantic.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] network: allowed: [] blocks all outbound network access, but the smoke test calls git log which may need to resolve remote refs depending on the checkout strategy. More critically, pai needs to reach the LLM proxy at api.githubcopilot.com.

💡 Suggestion

Compare with smoke-aider.md to confirm whether the smoke test inherits the shared engine network policy or fully overrides it. If allowed: [] is an override, the agent will be unable to reach any LLM endpoint and the smoke test will fail at the engine invocation step.

@copilot please address this.

Comment thread .github/workflows/shared/pydantic.md Outdated
version: "3.12"
pre-agent-steps:
- name: Install Pydantic AI CLI
run: |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] engine.version: "0.1.0" is hard-coded in the shared definition. When the shared file is imported, users who want to override the version must redeclare engine.version in their own workflow — but the precedence of that override is not documented.

💡 Suggestion

The PR description explains version override syntax, but that comment lives only in the HTML comment block at the bottom of the file. Move a one-line note into the visible YAML, or add a comment adjacent to the version key:

engine:
  id: pydantic-ai
  version: "0.1.0"  # override in your workflow: engine: { version: "x.y.z" }

This keeps the contract discoverable without reading the HTML comment.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Add Pydantic AI shared engine definition and smoke test

The shared engine definition is well-structured and consistent with existing engines (aider, goose). Two existing review threads cover MCP smoke-test coverage and unnecessary pip installs. One new issue found:

Log-parser: MCP failure lines leak into the assistant transcript — lines matching the MCP failure regex are added to mcpFailures but not continued, so they also fall through to pendingText.push(line.trim()) and appear as synthetic assistant text. See inline comment on line 103 of shared/pydantic.md.

Overall the PR is directionally sound. Blocking the MCP failure line leak before merge is recommended.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 62.2 AIC · ⊞ 5.5K

pendingText.push(msg);
}
} else {
pendingText.push(line.trim());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MCP failure lines match the mcpFailures push above but are not skipped afterward — they fall through to pendingText.push(line.trim()) and are emitted as synthetic assistant text in the log transcript. Every MCP error message ends up double-counted: once in mcpFailures and once as an assistant turn.

Fix by adding continue after the mcpFailures.push(...) call:

if (/MCP server .* failed|MCP.*connection.*error|Failed to connect to MCP/i.test(line)) {
  const serverMatch = line.match(/MCP server ['"x]?([^\s'"]+)['"x]?/i);
  mcpFailures.push(serverMatch ? serverMatch[1] : line.trim());
  continue; // prevent double-emit as transcript text
}

@copilot please address this.

@dsfaccini

dsfaccini commented Aug 7, 2026

Copy link
Copy Markdown

fyi, this will be valuable to have in place already, but we have some more work to do on the pydantic-ai and pydantic-ai-harness side of things

edit: some more info

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please refresh the branch if needed and run the pr-finisher skill to address any remaining review or validation items.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.54 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@dsfaccini we don't plan to own this long term but it is easier to iterate here to flush out bugs in gh-aw, then glabdly transfer and keep a copy.
@copilot see pydantic/pydantic-ai-harness#569 to compare notes. use "uv".

@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

(claude code compatibility is smart because a lot of tooling will "just work")

@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

This PR will be merged probably a bit broken because I need a "smoke-pydantic" action in main in order to run it.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@dsfaccini we don't plan to own this long term but it is easier to iterate here to flush out bugs in gh-aw, then glabdly transfer and keep a copy.
@copilot see https://github.com/pydantic/pydantic-ai...

Addressed in 9ca8622. The shared Pydantic engine now runs through uv (uv run pai run ...), and the lockfile was recompiled accordingly.

@copilot please refresh the branch if needed and run the pr-finisher skill to address any remaining review or validation items.

Generated by [👨‍🍳 PR Sous Chef](https://github.com/github/g...

Done in 9ca8622. I refreshed the branch context, addressed the remaining actionable item (use uv), recompiled, and ran local validation + review/security checks.

@pelikhan

pelikhan commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@copilot add a step using uv api version to predownload pai

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add a step using uv api version to predownload pai

Added uv run pai --version as a pre-agent preload step and regenerated the lockfile in 382bfaf.

@pelikhan
pelikhan merged commit 0e301e6 into main Aug 7, 2026
1 check failed
@pelikhan
pelikhan deleted the copilot/pydantic-ai-agentic-engine branch August 7, 2026 20:57
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pydantic AI as an agentic engine

5 participants