Rename harness `subagents`, `filesystem` and `spend` packages to their capability names and align store, `ACP*` and `*Error` class names
- Closes #11321
Aligns harness class, module and package names with the naming conventions listed in #11321. Every renamed public name still works through a deprecation shim that emits HarnessDeprecationWarning.
[!WARNING]
Compatibility impact: Code that imports pydantic_ai_harness.subagents, .filesystem or .spend, or the old class names listed below, now gets a HarnessDeprecationWarning. Code that runs with warnings-as-errors will fail until it switches to the new names. Error messages and reprs show the new class names.
Why this can ship in a minor release: Every old import path and class name still resolves to the same object through a shim (the _warn.warn_module_renamed / warn_class_renamed pattern already used for context/, docs/, cache_stability/ and overflowing_tool_output/). The only names renamed without an alias are private ones, in _-prefixed modules.
Migration: Change the imports:
pydantic_ai_harness.subagents → pydantic_ai_harness.sub_agents
pydantic_ai_harness.filesystem → pydantic_ai_harness.file_system
pydantic_ai_harness.spend → pydantic_ai_harness.spend_limits
experimental.acp: AcpSession, AcpSessionConfig, AcpFileSystemToolset, AcpTerminalToolset → ACPSession, ACPSessionConfig, ACPFileSystemToolset, ACPTerminalToolset
memory: FileStore, InMemoryStore → FileMemoryStore, InMemoryMemoryStore
media: DiskMediaStore → FileMediaStore
tool_output_limits: LocalFileStore, WorkspaceStore → LocalFileOverflowStore, WorkspaceOverflowStore
- Logging: these packages' loggers are now named
pydantic_ai_harness.sub_agents.*, pydantic_ai_harness.file_system.* and pydantic_ai_harness.spend_limits.*. Move any level or handler configured on pydantic_ai_harness.subagents, .filesystem or .spend to the new names.
What changed
- Packages (R8, R9, R12):
filesystem/,subagents/andspend/move tofile_system/,sub_agents/andspend_limits/, the snake_case ofFileSystem,SubAgentsandSpendLimits. That matches their event namespaces. The old paths are shim packages that re-export the same__all__. Tests, docs andclai2imports use the new paths. - Public classes (R1, R2, R3, R6, R7): the classes listed above are renamed. Each old name is a module-level
__getattr__alias that warns and is not in__all__. The deprecatedexperimental.mediaandoverflowing_tool_output/experimental.overflowshims keep exporting their old names. - Classes in private modules (no alias, because they are not exported):
RenderJsonTransport→RenderJSONTransport,LineTooLong→LineTooLongError,RipgrepMissing→RipgrepNotFoundError,_McpSafetyHints→_MCPSafetyHints,_StaleHandle→_StaleHandleError,_BudgetExhausted→_BudgetExhaustedError,_ToolArguments/_RunCodeArguments/_WorkflowArguments→*Args. - Modules:
compaction/_context_usage_events.py→compaction/_events.py(R10). - Regression tests: each package's
test_deprecated_names.pychecks three things: every old class name warns and resolves to its new class; each package shim warns and re-exports the new package, and its deprecated names warn at the caller and are absent from the new package; and the deprecated modules keep their old names.
Choices I made (no questions asked)
- #7
ConversationConflictis kept. It mirrors core'spydantic_ai.conversation_store.ConversationConflict. Renaming only the harness copy would split one concept across two names; renaming both is a core change outside this issue. - #23
guardrails/detectors.pyand #25step_persistence/recovery.pystay public. R11 asks to confirm they are meant to be public. They are: the guardrails README, the harness skill and the step-persistence README document them as import paths (from pydantic_ai_harness.guardrails.detectors import redact_secrets). McpServerinexperimental.acpis unchanged. It re-exports the ACP SDK's name; it isn't a harness class.clai2saved plugins:MOVED_FACTORIESrewrites storedpydantic_ai_harness.subagents:SubAgentsrows topydantic_ai_harness.sub_agents:SubAgents, so existing settings databases never import the deprecated shim.INCLUDEDnames only the new factory.- Already-deprecated names stay on the old paths only. These are the old
subagentsevent names,MINIMUM_EFFORT_FLOOR/clamp_effort,spend.SpendCompositionWarningandfilesystem.FileChangeRequestEvent. They are served by thesubagents,spendandfilesystemshims and are not insub_agents,spend_limitsorfile_system, so the new paths start without deprecated exports. - Rename warnings from the old package shims name the new module.
warn_class_renamedgains an optionalnew_module, sopydantic_ai_harness.subagents.DelegationEndEventpoints straight topydantic_ai_harness.sub_agents.DelegationFinishedEvent. - The gh-aw shim (
.github/scripts/pydantic_ai_gh_aw_shim/_backends.py) importsfile_systemand falls back tofilesystem. The gh-aw engine pins harness0.64.0, which predates the rename. The fallback can be dropped when that pin moves. - Old class aliases are runtime-only (
__getattr__), like the existingguardrailsand #12233/#11322 aliases. Type checkers report them asobjectuntil users switch to the new names. A possible follow-up isTYPE_CHECKINGredundant aliases, asDockerSandboxhas. - The deprecation shims emit
HarnessDeprecationWarningon import or attribute access, following the existing_warnhelpers.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
The API compatibility waivers in .github/api-compatibility-waivers/ cover each finding the gate reports against v2.68.0.