Skip to content

Commit b279632

Browse files
committed
Add Deep Agents migration skill
1 parent 2ca99fe commit b279632

32 files changed

Lines changed: 5622 additions & 7 deletions

.claude-plugin/marketplace.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
},
3333
{
3434
"name": "pydantic-ai-harness",
35-
"description": "Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness, currently Code Mode for collapsing many tool calls into one sandboxed Python execution",
36-
"version": "0.1.0",
35+
"description": "Extend Pydantic AI agents with harness capabilities and migrate LangChain Deep Agents projects to Pydantic AI",
36+
"version": "0.2.0",
3737
"author": {
3838
"name": "Pydantic",
3939
"email": "support@pydantic.dev"

CONTRIBUTING.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,21 @@ Synced skills are owned by the library they document. Libraries host those skill
1212
| `logfire-instrumentation` | [`pydantic/logfire`](https://github.com/pydantic/logfire)`logfire/.agents/skills/logfire-instrumentation/` |
1313
| `building-pydantic-ai-agents` | [`pydantic/pydantic-ai`](https://github.com/pydantic/pydantic-ai)`pydantic_ai_slim/pydantic_ai/.agents/skills/building-pydantic-ai-agents/` |
1414
| `pydantic-ai-harness` | [`pydantic/pydantic-ai-harness`](https://github.com/pydantic/pydantic-ai-harness)`pydantic_ai_harness/.agents/skills/pydantic-ai-harness/` |
15+
| `migrate-deep-agents-to-pydantic-ai` | This repository — `plugins/pydantic-ai-harness/skills/migrate-deep-agents-to-pydantic-ai/` |
1516

1617
A daily workflow (`.github/workflows/sync-from-upstream.yml`) clones each upstream listed above, runs `rsync -a --delete` into both destinations, and opens a PR. CI (`scripts/check-skill-sync.sh`) enforces that plugin and standalone skill copies stay byte-identical.
1718

1819
**Anything you add directly inside a synced skill directory will be wiped on the next sync.** To change synced skill content, send a PR upstream. Everything else in this repo (plugin metadata, repo-root files, `.github/`, `scripts/`) is fine to edit here.
1920

20-
## Adding a new skill
21+
The Deep Agents migration skill is repository-owned because it spans Deep Agents, Pydantic AI core, and multiple Harness capabilities. Its plugin copy is canonical and `scripts/check-skill-sync.sh` keeps the standalone copy byte-identical.
22+
23+
## Adding a new synced skill
2124

2225
1. Ensure the skill exists in the library at `<package-dir>/.agents/skills/<skill-name>/`.
2326
2. Add a `sync_skill` entry to `scripts/sync-from-upstream.sh`.
2427

28+
For a repository-owned cross-project skill, add the canonical plugin copy, mirror it under `skills/`, and add the pair to `scripts/check-skill-sync.sh`.
29+
2530
## Manually triggering a sync
2631

2732
Actions → **Sync skills from upstream** → Run workflow.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Logfire and Pydantic AI plugins for [Claude Code](https://claude.com/claude-code
99
| [logfire](plugins/logfire/) | Claude Code, Codex, Cursor | Add Logfire observability and query/debug telemetry | Claude commands `/instrument`, `/debug`, `/query`; Codex/Cursor skills and MCP tools |
1010
| [logfire-exporter](plugins/logfire-exporter/) | Codex | Export Codex activity traces to Logfire | Codex lifecycle hooks |
1111
| [ai](plugins/ai/) | Claude Code | Build AI agents with Pydantic AI | Pydantic AI skill docs |
12-
| [pydantic-ai-harness](plugins/pydantic-ai-harness/) | Claude Code | Extend Pydantic AI agents with harness capabilities (Code Mode) | Pydantic AI Harness skill docs |
12+
| [pydantic-ai-harness](plugins/pydantic-ai-harness/) | Claude Code | Extend Pydantic AI agents and migrate Deep Agents projects | Harness capability and Deep Agents migration skills |
1313

1414
## Install In Claude Code
1515

@@ -84,3 +84,4 @@ The `skills/` directory contains standalone SKILL.md files compatible with 30+ a
8484
| [logfire-ui](skills/logfire-ui/) | Open Logfire project pages, live views, traces, and Explore filters |
8585
| [building-pydantic-ai-agents](skills/building-pydantic-ai-agents/) | Build LLM-powered agents with Pydantic AI — tools, capabilities, streaming, testing |
8686
| [pydantic-ai-harness](skills/pydantic-ai-harness/) | Extend Pydantic AI agents with harness capabilities like Code Mode (sandboxed `run_code`) |
87+
| [migrate-deep-agents-to-pydantic-ai](skills/migrate-deep-agents-to-pydantic-ai/) | Convert LangChain Deep Agents projects to Pydantic AI and Harness capabilities |

plugins/pydantic-ai-harness/.claude-plugin/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pydantic-ai-harness",
3-
"description": "Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness, currently Code Mode for collapsing many tool calls into one sandboxed Python execution",
4-
"version": "0.1.0",
3+
"description": "Extend Pydantic AI agents with harness capabilities and migrate LangChain Deep Agents projects to Pydantic AI",
4+
"version": "0.2.0",
55
"author": {
66
"name": "Pydantic",
77
"email": "support@pydantic.dev"

plugins/pydantic-ai-harness/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ Extend [Pydantic AI](https://ai.pydantic.dev/) agents with batteries-included ca
77

88
- SKILL.md covering the harness capability model (`capabilities=[...]`)
99
- Reference docs for Code Mode — wrapping eligible tools into a single sandboxed `run_code` tool so the model orchestrates many tool calls in one Python execution
10+
- A Deep Agents migration skill with a deterministic project inventory, feature-by-feature mappings, implementation recipes, large-project playbooks, custom capability patterns, and parity validation
1011

11-
For the core framework (agents, tools, structured output, streaming, testing), use the `ai` plugin.
12+
For the core framework (agents, tools, structured output, streaming, testing), use the `ai` plugin. The migration skill composes those core primitives with Pydantic AI Harness capabilities and calls out gaps that remain application concerns.
1213

1314
## Install
1415

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: migrate-deep-agents-to-pydantic-ai
3+
description: Converts and audits Python LangChain Deep Agents applications, create_deep_agent projects, and Deep Agents Code or deploy layouts using Pydantic AI plus pydantic-ai-harness capabilities. Use when migrating, reviewing, or validating a Deep Agents project, or a LangGraph harness that specifically uses Deep Agents-style middleware, backends, HarnessProfile behavior, AGENTS.md or skills, subagents, sandboxes, planning, memory, streaming, approvals, or persistence.
4+
---
5+
6+
# Migrate Deep Agents to Pydantic AI
7+
8+
Translate behavior and operational guarantees, not constructor arguments. Keep application orchestration outside the agent where it already owns queues, sandboxes, tenancy, deployment, or external side effects.
9+
10+
## Assume Semantic Deltas
11+
12+
- Treat every mapping, including `direct`, as a hypothesis rather than a claim of identical behavior.
13+
- Read [the semantic delta and spike guide](references/SEMANTIC-DELTAS.md) before choosing the target architecture.
14+
- Show users every known or plausible change in prompts, tools, state, files, child results, errors, events, approvals, persistence, budgets, and side effects.
15+
- Spike each high-risk or uncertain mapping on the installed source and target versions. Discard the research probe; rewrite only lasting application contracts as project regression tests.
16+
- Keep target shape, parity disposition, and evidence status separate. A `direct` target can still have `unknown` parity and `unproved` evidence. Retain the old path or add an adapter instead of implying parity.
17+
18+
## Workflow
19+
20+
1. **Freeze the contract.** Record entry points, outputs, tools, filesystem and shell boundaries, subagent topology/state handoff, context policy, persistence, approvals, streaming, budgets, deployment surfaces, the resolved HarnessProfile, and the fully assembled effective prompt. Do not remove Deep Agents yet.
21+
2. **Inventory the project.** Resolve `SKILL_DIR` to the absolute directory containing this `SKILL.md`, run the bundled scanner from any working directory, and verify its findings manually. Read [the migration map](references/MIGRATION-MAP.md) for every detected feature.
22+
23+
```bash
24+
SKILL_DIR="<absolute path to this skill>"
25+
python3 "$SKILL_DIR/scripts/inventory_deepagents.py" <project-root>
26+
```
27+
3. **Inspect installed APIs.** Check the project's locked versions and importable symbols. Treat Harness APIs as version-sensitive; prefer the installed package, its bundled README files, and official docs over remembered imports.
28+
4. **Build the delta ledger.** Create one row per independently testable invariant; split broad features such as subagents or persistence into state, result, routing, failure, concurrency, and recovery rows. Record target candidate, plausible delta, spike evidence, user impact, and rollback. Keep three fields independent: target shape (`direct`, `composed`, `custom`, `retain externally`, or `unknown`), parity disposition (`exact`, `compatible`, `intentional change`, or `unknown`), and evidence status (`unproved`, `source-inspected`, `spike-observed`, `regression-locked`, or `production-observed`).
29+
5. **Choose the target shape.** Use a plain `Agent` for one agent loop, `SubAgents` for occasional delegation, `DynamicWorkflow` for scripted fan-out/chaining, `pydantic_graph` for an application state machine, and a durable runtime for crash-safe orchestration.
30+
6. **Build one vertical slice.** Port typed deps, one tool family, output type, and one representative request. Keep adapters around existing LangChain tools only as a temporary seam.
31+
7. **Add harness behavior deliberately.** Compose only the capabilities the contract needs. Read only the matching recipe sections routed below.
32+
8. **Close real gaps with executable workarounds.** Read [the validated workaround guide](references/WORKAROUNDS.md) for every `composed`, `custom`, or `retain externally` target shape. Copy or adapt the bundled capability, toolset, facade, or application-boundary assets; run the same source-contract assertion against the target. Do not stop at documenting a missing equivalent.
33+
9. **Migrate by risk.** Port read-only tools before writes, local runs before persistence, synchronous delegation before background work, and deterministic hooks before deployment integrations.
34+
10. **Verify parity.** Follow [the validation guide](references/VALIDATION.md). Compare outputs, tool traces, budgets, failure modes, approval pauses, resume behavior, and side effects—not just whether the new agent answers.
35+
11. **Cut over reversibly.** Keep the old path behind a flag until representative evals pass; then remove framework-specific adapters and dependencies.
36+
37+
## Translation Rules
38+
39+
- Prefer typed dependencies (`deps_type` + `RunContext`) over global clients or graph context dictionaries.
40+
- Prefer Pydantic output models over prompt-only response formats.
41+
- Prefer toolsets for related tools, capabilities for reusable tools plus instructions or hooks, and `Hooks` for narrow interception.
42+
- Treat static repository instructions, writable memory, message history, and durable checkpoints as four different concerns.
43+
- Enforce permissions in tools, toolsets, sandboxes, and application credentials. Prompt instructions are not a security boundary.
44+
- Bound every recursive or fan-out path with request, token, call-count, timeout, and external-side-effect limits as appropriate.
45+
- Preserve model-visible tool errors for recoverable mistakes; propagate infrastructure and invariant failures unless the contract explicitly contains them.
46+
- Do not treat Harness `Shell` command filters as isolation. Use an OS/container/remote sandbox when untrusted model-written commands require a hard boundary.
47+
- When an asset tool requires approval, include `DeferredToolRequests` in the agent output or install a tested deferred-call handler; persist messages and pending application state before returning control.
48+
- If Code Mode is present, use an explicit safe-tool selector such as `CodeMode(tools={'code_mode': True})`; never use `tools='all'` with guarded asset tools.
49+
- Do not describe `StepPersistence` as a full LangGraph checkpoint. It records events and provider-valid message snapshots; use durable execution or application state for stronger resume guarantees.
50+
51+
## Project Patterns
52+
53+
Read only the matching project playbook: [Open SWE](references/PROJECT-PATTERNS.md#open-swe), [Deep Research](references/PROJECT-PATTERNS.md#deep-research), [Content Builder](references/PROJECT-PATTERNS.md#content-builder), [Text-to-SQL](references/PROJECT-PATTERNS.md#text-to-sql), [deploy coding](references/PROJECT-PATTERNS.md#deploy-coding-agent), or [deploy GTM](references/PROJECT-PATTERNS.md#deploy-gtm-agent). Use it as a decomposition example, not a copy-paste template.
54+
55+
## Reference Routing
56+
57+
- Always use [the minimal agent](references/RECIPES.md#a-minimal-agent) and [typed dependencies](references/RECIPES.md#typed-tools-and-dependencies) when implementing.
58+
- Read [the composed long-horizon agent](references/RECIPES.md#a-composed-long-horizon-agent) only when inventory justifies planning, repository context, filesystem, shell, overflow, or compaction.
59+
- Read [delegation](references/RECIPES.md#subagents) or [dynamic workflows](references/RECIPES.md#dynamic-workflows) only when inventory finds child agents or fan-out.
60+
- Read [context and memory](references/RECIPES.md#context-memory-and-history) or [filesystem, shell, and Code Mode](references/RECIPES.md#filesystem-shell-and-code-mode) only for those detected surfaces.
61+
- Read [approvals](references/RECIPES.md#approvals-and-policy), [streaming](references/RECIPES.md#streaming-and-mid-run-messages), [persistence](references/RECIPES.md#persistence), or [LangChain adapters](references/RECIPES.md#transitional-langchain-tools) only when required.
62+
- Read [skill capabilities](references/EXTENDING-THE-HARNESS.md#turn-one-skill-into-a-deferred-capability), [skill catalogs](references/EXTENDING-THE-HARNESS.md#load-a-directory-of-existing-skills), [background jobs](references/EXTENDING-THE-HARNESS.md#build-background-subagents), [remote sandboxes](references/EXTENDING-THE-HARNESS.md#wrap-a-remote-sandbox), [middleware](references/EXTENDING-THE-HARNESS.md#translate-middleware), or [ordered policy](references/EXTENDING-THE-HARNESS.md#implement-ordered-policy) only for a matching gap.
63+
- For planning, virtual state files, source-shaped invocation, child JSON/state merge, native approval, background jobs, remote sandboxes, or skill catalogs, start from the tested modules in `assets/parity_workarounds/` rather than rewriting them from memory.
64+
65+
## Deliverables
66+
67+
Produce:
68+
69+
- an inventory and behavior contract;
70+
- a semantic delta ledger with spike evidence for every high-risk or uncertain mapping;
71+
- a mapping with target shape, parity disposition, and evidence status for every feature;
72+
- a staged migration plan;
73+
- migrated code and deterministic tests when implementation is requested;
74+
- a named executable workaround and target parity test for every non-`direct` mapping;
75+
- an explicit gap and risk register;
76+
- evidence from parity tests and traces.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface:
2+
display_name: "Deep Agents to Pydantic AI"
3+
short_description: "Migrate Deep Agents with tested Pydantic AI workarounds"
4+
default_prompt: "Use $migrate-deep-agents-to-pydantic-ai to migrate this Deep Agents project with executable Pydantic AI workarounds and evidence-based parity checks."

0 commit comments

Comments
 (0)