Rename harness `subagents`, `filesystem` and `spend` packages to their capability names and align store, `ACP*` and `*Error` class names

Merged
MP
21d ago
+2021-1330

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/ and spend/ move to file_system/, sub_agents/ and spend_limits/, the snake_case of FileSystem, SubAgents and SpendLimits. That matches their event namespaces. The old paths are shim packages that re-export the same __all__. Tests, docs and clai2 imports 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 deprecated experimental.media and overflowing_tool_output / experimental.overflow shims 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.py checks 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 ConversationConflict is kept. It mirrors core's pydantic_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.py and #25 step_persistence/recovery.py stay 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).
  • McpServer in experimental.acp is unchanged. It re-exports the ACP SDK's name; it isn't a harness class.
  • clai2 saved plugins: MOVED_FACTORIES rewrites stored pydantic_ai_harness.subagents:SubAgents rows to pydantic_ai_harness.sub_agents:SubAgents, so existing settings databases never import the deprecated shim. INCLUDED names only the new factory.
  • Already-deprecated names stay on the old paths only. These are the old subagents event names, MINIMUM_EFFORT_FLOOR/clamp_effort, spend.SpendCompositionWarning and filesystem.FileChangeRequestEvent. They are served by the subagents, spend and filesystem shims and are not in sub_agents, spend_limits or file_system, so the new paths start without deprecated exports.
  • Rename warnings from the old package shims name the new module. warn_class_renamed gains an optional new_module, so pydantic_ai_harness.subagents.DelegationEndEvent points straight to pydantic_ai_harness.sub_agents.DelegationFinishedEvent.
  • The gh-aw shim (.github/scripts/pydantic_ai_gh_aw_shim/_backends.py) imports file_system and falls back to filesystem. The gh-aw engine pins harness 0.64.0, which predates the rename. The fallback can be dropped when that pin moves.
  • Old class aliases are runtime-only (__getattr__), like the existing guardrails and #12233/#11322 aliases. Type checkers report them as object until users switch to the new names. A possible follow-up is TYPE_CHECKING redundant aliases, as DockerSandbox has.
  • The deprecation shims emit HarnessDeprecationWarning on import or attribute access, following the existing _warn helpers.

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.