Python Dependency Resolution#

Python Tools may optionally declare index distribution requirements in agent.json:

"runtime": {
  "type": "python",
  "version": "3.11",
  "dependencies": ["pydantic>=2.8,<3"]
}

version remains a minimum Python version, not an exact interpreter pin. Dependencies are Python-only; Node declarations, invalid requirement syntax, and overlapping duplicate distribution names fail lint. Combine constraints for one distribution in a single requirement. Disjoint platform/Python markers and extras are supported. Local paths, editable installs and direct URLs are not supported dependency sources.

Declare Python dependencies under runtime.dependencies instead of bundling installed distributions in the Tool payload; AgentPM installs them separately. If an upload exceeds the Registry's size policy, remove bundled dependency files from the payload after declaring them. Declaration does not remove existing files selected by files automatically.

Prepare and publish#

Use AgentPM CLI 0.1.43 or newer for the complete publish/install/SDK workflow. Python 3.11 or newer must already be installed when a Tool declares that minimum. AgentPM manages its dependency engine; authors and consumers do not need an installed uv, a uv project or a project uv.lock.

New Python Tool publications use one immutable release with an artifact inventory, even for a source-only Tool without declared dependencies. A portable payload has one any artifact; native payloads identify their build target. Node Tools and other package kinds retain the single-archive format. Historical Python versions retain their original format and remain installable. See release integrity and CI publishing.

With normal publish credentials and a namespace you own:

agentpm lint --strict
agentpm publish --dry-run --refresh-python
git diff -- agent.lock
# Review and commit agent.json and agent.lock before publication or CI builds.
agentpm publish --namespace your-namespace

Archive uploads stream from disk. The Registry returns its current per-artifact and aggregate release size limits before upload. A partial or failed upload does not make a partial release installable.

In an interactive terminal, Python dependency preparation first displays Preparing Python dependencies…, covering both resolution and prepared-lock reuse. The dry run reports a checkmark-prefixed resolution summary with the distribution count and full digest, and prepares the normal Tool archive; it does not upload anything. It writes the exact Python resolution and its input fingerprint to the local:tool root in agent.lock. This describes the Tool being authored; it is separate from the lock's packages map of installed dependencies. The local Tool does not need a synthetic installed-package entry or a placeholder integrity hash.

Normal publication requires a current matching resolution in that lock. Missing or stale state fails before acquiring a resolver or starting an upload. Prepare it with a dry run, review the dependency changes and commit the lock. Every CI target build must use that same committed resolution, rather than independently resolving against the live package index. A fresh checkout with a valid lock needs neither a cached resolution nor uv to reuse the recorded result.

--refresh-python requires --dry-run. A live publish with that flag is rejected before reading credentials, resolving dependencies or changing the lock, even when the existing lock is valid. Refresh and review the lock first, then publish without the refresh flag.

The published Tool archive contains generated agentpm-python.json metadata: the Tool's resolution and its full canonical SHA-256 digest. This filename is reserved for AgentPM. The publisher's root agent.lock is omitted from dependency-bearing Tool archives, even when listed in files; unrelated workspace dependencies are not part of this Tool's dependency contract. The Registry verifies that the artifact's manifest, resolution and digest match its publish reservation before making the version available.

Installing that Tool records its resolution on the consumer's package entry. Full lock regeneration preserves the local Tool's own resolution and fingerprint for the matching project while rebuilding installed packages from the Registry plan. Preserved stale state still cannot pass the publication freshness check. An older Tool-project root named local:agent is replaced by local:tool on the next lock regeneration/preparation; one project does not receive both roots.

Running plain agentpm install inside a Tool project now succeeds even with no AgentPM package dependencies and creates or regenerates agent.lock with its local:tool root. Use the dry-run preparation above to create or refresh the Tool's Python dependency resolution.

Dependency-bearing state uses lockfile version 4. Existing v2/v3 locks remain readable and keep their existing serialization when they do not need newer capabilities. Updated CLIs reject unsupported future lock versions before rewriting them; this protection does not change already-released older CLIs. Locks remain pretty-printed so dependency updates are reviewable. Unchanged installs preserve the lock's existing bytes and timestamp. Regeneration never lowers an existing lock version. Removing Python dependency declarations drops the local root's resolution and fingerprint on the next normal install; the lock may keep its existing version 4 after that cleanup. A project with no Python state does not otherwise need a v4 upgrade. Frozen installs reject older locks that cannot represent required Python state and direct you to regenerate with agentpm install without --frozen.

Agent and Skill publication skips Python resolution lock reads; an unrelated malformed or unsupported future-version agent.lock does not block their publication. New Python Tool releases without declared dependencies omit the Python resolution and do not provision dependency environments. Historical vendored Python versions keep their original runtime behavior.

Tool Payload Compatibility#

New-format releases can contain one portable any payload or artifacts for specific supported platforms. Installation verifies the signed release, chooses the exact platform artifact before a portable fallback, checks its bytes and prepares the recorded Python dependency environment before reporting success. The portable lock records release integrity; selected payloads and interpreter state stay under .agentpm/. See install for compatibility errors, strict verification flags, machine output and transfer limits.

Python Tool packaging inspects the files in the completed archive and reports their compatibility, for example:

✓ Tool payload: any (format: tar.gz)

any means every shipped file qualifies as recognized portable source/data or a recognized portable binary asset. Declaring Python dependencies does not narrow this classification: their wheels are installed separately for the consumer. A source-only Tool using Pydantic can therefore have an any payload even though Pydantic depends on native code.

Bundled native libraries/executables, compiled Python files, embedded environment snapshots or installed-distribution state, unknown formats and unrecognized binary content receive the current machine's concrete target, such as aarch64-apple-darwin. This is conservative: AgentPM does not cross-compile or certify a bundled foreign binary for another target. Pure source under _vendor can still qualify as any; bundling its native components cannot. Unknown executables and symlinks also prevent an any claim. The executable bit on a Python source file alone does not make it native. Embedded .whl files remain blocked; use declared dependencies instead. Missing literal paths in files fail packaging rather than being omitted.

Text candidates must contain valid UTF-8 without binary controls or native signatures. Extension matching and special-name matching are case-insensitive. The complete portable-format inventory is the same checked-in data the CLI consumes, including text suffixes, special basenames, prefix rules and binary signatures. It includes Python source, notebook JSON, templates, queries and .in inputs such as MANIFEST.in and requirements.in. Shipping these inputs does not execute builds or resolve additional dependencies. Unfamiliar formats, including JavaScript/TypeScript, RTF and unlisted media, remain target-specific.

Dotenv matching uses the file's basename: exact .env or prefix .env.. Thus .env.example qualifies as text configuration, while .envrc, .environment and .gitignore do not receive that exception. This classification does not inspect configuration for secrets. A single-file .egg-info or a PKG-INFO inside an .egg-info directory can qualify as text metadata; other members still undergo normal checks. Metadata stays in the archive. .dist-info, virtualenv/site-packages state and bytecode remain conservative.

Directory Collection and Explicit Inclusion#

For Python Tools, a literal directory in files is traversed with a small, case-insensitive incidental-file policy. It skips Git metadata, Python bytecode cache/environment directories, OS metadata and dotenv files. Environment names and marker names come from the same inventory used by compatibility checks. A directory containing a direct regular-file pyvenv.cfg marker is skipped as a whole environment, even when it has a custom name. AgentPM does not execute Python or read the marker contents to detect it.

Only exact .env.example is kept by the incidental dotenv exception, including case variants. .env.sample, .env.template and .env.dist are deliberately skipped unless explicitly included. This is a narrow convention, not a promise that example files contain no secrets. The collection policy inventory defines the exact names; there is no .gitignore interpretation, credential scan or general-purpose ignore system.

Explicitly listing an excluded file preserves it. Explicitly listing an excluded directory preserves its whole subtree; listing only its ordinary parent does not disable filtering below that parent. For example:

"files": ["mypkg", "mypkg/__pycache__", ".env.template"]

Here mypkg is traversed normally, the explicitly requested cache subtree is preserved, and .env.template is included deliberately. Separate explicit children of otherwise skipped directories are still collected, regardless of manifest entry order. Required entrypoint files are retained without pulling in their entire enclosing environment. Missing explicit paths still fail, and an override never bypasses signature, blocked-archive, safe-path or entry-limit checks. Symlink targets are not followed to collect additional files.

Intentional _vendor, .egg-info, .dist-info, native files and templates remain subject to the normal file rules. Makefile, Dockerfile, CODEOWNERS and project configuration names are not automatically removed or newly classified portable; surviving unrecognized files can still narrow compatibility.

Dry runs and publication report omitted traversal paths and explicit overrides as Info: diagnostics on stderr, including quiet/CI use. Reports identify the policy reason and skipped directory itself, not an invented count of files inside an unvisited tree. These decisions also remain in structured build diagnostics. An otherwise portable payload can still be any with informational diagnostics; they neither narrow compatibility nor change --strict behavior.

Omissions change the next archive's bytes. Reproducing bytes requires the same source, manifest, collection policy and build tooling; a CLI upgrade can change policy. Existing published archives keep their bytes and read/install behavior.

Binary Recognition and Diagnostics#

Recognized binary assets include PNG, JPEG, WebP, PDF and WOFF2. Their bounded header checks come from the inventory above and replace text validation. All required checks for a format must match. This is format recognition, not full structural validation, decoding or malware scanning.

A recognized binary suffix with missing, truncated or disagreeing signature fails packaging. For example, GIF bytes named icon.png must be renamed to the actual format, or replaced with valid PNG data; update manifest file paths and code/template references after renaming. A correctly named .gif is currently unrecognized and still narrows the target. Previous acceptance does not exempt the next publication of a Tool from this check. Existing published versions keep their read/install behavior, and cannot be overwritten.

Narrowing emits a warning to stderr naming the file, reason and concrete build target. It does not fail publication by itself or change --strict manifest-lint semantics. Mismatches emit an error with corrective guidance and a nonzero exit, before any publication request; an existing valid local archive is preserved. Warnings/errors remain visible with --quiet and in non-interactive CI output.

The CLI generates a build descriptor with target, format and structured diagnostics and includes it in publish metadata as artifact. Successful portable builds can carry informational collection decisions; narrowed builds also carry their compatibility warnings. The array is empty when no diagnostics apply. Failed builds retain structured errors instead of a successful descriptor. The current publish command has no --machine mode. Dry runs display the classification without uploading. There is no new author-maintained file, and this descriptor is not written into agent.json, agent.lock or agentpm-python.json. The Registry stores the complete immutable artifact inventory for new Python releases. Install chooses the consumer's exact target first, then any only when there is no exact-target artifact. Previously published legacy Tools keep unknown compatibility; no target claim is invented for them. any describes the shipped files, not a guarantee that source code's OS assumptions, external services or dependency wheels work everywhere.

Install and Run a Dependency-Bearing Tool#

With a suitable Python already installed on the consumer machine:

agentpm install @your-namespace/your-tool@0.1.0
agentpm run @your-namespace/your-tool@0.1.0 --input '{}'

Install downloads and verifies the Tool, then uses AgentPM's pinned, verified uv to create a private Python environment under .agentpm/runtimes/python/. The environment is separate from the extracted Tool and keyed by package/version, consumer target, selected Python executable, implementation, major/minor version, ABI and resolution digest. Kernel release/build strings and Python patch versions are not directory keys. Python selection follows the existing runtime minimum and AGENTPM_PYTHON rules. AgentPM does not download a Python interpreter or change your global packages.

Provisioning replays the exact applicable recorded distribution set. It never selects newer versions or adds an unrecorded dependency. Every installed wheel must match a recorded SHA-256. Source builds are disabled, even when the resolution includes a source-distribution hash. Missing distributions, digest mismatches and lack of a wheel for the selected platform/Python have distinct errors. An incomplete recorded dependency set fails instead of being expanded.

Install is only finalized after provisioning and dependency checks succeed. An interrupted or failed environment has no completion record and cannot be used by run. Retrying install converges to the recorded set; a ready matching environment is reused without index access. The managed uv cache is also reused. Runtime directories and environment fingerprints stay local; they are never written into the portable agent.lock. Add .agentpm/ to your project's .gitignore so managed runtimes and installed payloads are not committed with source.

agentpm run automatically executes with the environment's Python and checks its fingerprint and installed package inventory first. If Python selection, target or recorded resolution changed, follow the actionable agentpm install guidance. Use agentpm install --refresh to repair damaged installed packages. All Python environment markers are reevaluated at install and run. A routine kernel update or compatible Python patch update reuses the same environment when the applicable package set and live interpreter checks still match. If a marker change selects different locked packages, reinstall syncs them in that same directory. If a Python update removes or relocates the venv's underlying binary, reinstall repairs that directory instead of choosing a new one solely because of the patch version. A different selected executable, major/minor version or ABI uses a separate environment. Old environments for those distinct identities are retained; AgentPM does not automatically prune them. Run does not silently download dependencies or fall back to global Python. Managed Tool execution clears PYTHONHOME and PYTHONPATH after merging the environment, including manifest values and invocation overrides, so external import paths cannot replace the locked dependencies. Tool-local package imports and explicit author-written _vendor imports still work. Tools without declared Python dependencies retain their existing environment behavior. Concurrent provisioning and Tool execution are guarded by local file locks; retry install after a running Tool finishes if the environment is in use.

Harness dispatches installed Tools through agentpm run --machine and uses the same environment checks. Its preflight reports an unavailable/stale environment with reinstall guidance. Author-written _vendor imports remain supported; install warns when a dependency-bearing Tool also includes likely vendored dependency content, because conflicting versions can undermine portability. This advisory scan checks at most 2000 entries through depth 4. If it finds no vendored content but reaches an entry/depth limit or skips unreadable entries, it warns that the scan is incomplete and identifies what was skipped.

For an example with real Pydantic imports and a native pydantic-core dependency, see validate-order source and development/consumer instructions. Publish that source into your namespace before using its consumer commands; the example does not imply an existing published package.

For an existing Tool migrating away from vendored dependencies, see the summarize-text source. Its manifest declares OpenAI, its author lock records the complete dependency set, and consumers install native wheels into their managed environment. Remove old vendored dependency directories from the new artifact instead of carrying publisher-specific binaries forward. Existing published vendored versions remain unchanged.

The Registry's /install/resolve endpoint limits the complete dependency plan to 8 MiB of compact JSON, including all package entries, Python resolutions, the response envelope and final newline. Each Tool's Python resolution still has its separate 2 MiB limit. The Registry checks the aggregate while assembling distinct entries and returns HTTP 422 (resolution_too_large) instead of a partial plan when the budget is exceeded. Reduce the project's root dependencies to resolve a smaller graph. This budget is separate from incoming request limits and local lockfile size; pretty-printed locks can be larger than the compact response.

What AgentPM Resolves#

AgentPM uses its pinned internal uv to resolve the declared requirements and their indirect dependencies across the supported Mac, Linux and Windows targets. The result records exact distribution versions, conditional environment markers, and SHA-256 digests for applicable wheels and source distributions. It does not record the author's selected wheel, platform, interpreter path or environment. Recording a source-distribution digest does not enable install-time source builds; the installer remains wheel-only. Resolution creates a fresh temporary internal uv lock with source builds disabled, then exports that exact lock with all distribution digests. A dependency requiring a source build for its metadata fails resolution instead of running that build backend.

Matching committed resolutions are reused, not refreshed on every publish. Changing requirements, the Python minimum, supported targets or AgentPM's resolver pin invalidates the input fingerprint. publish --dry-run --refresh-python explicitly re-resolves. Disposable preparation records live in the OS per-user AgentPM cache directory under python-resolutions/; they accelerate preparation but are never the source of truth for publication. Removing that cache cannot change a valid committed resolution. The old project target/agentpm/python-resolutions/ location is no longer read or written; prepare a v4 lock before publishing with the new CLI. Index contents can change between resolutions: the resolver pin fixes resolution semantics, not future index contents. Reproducibility comes from retaining the exact resolution and later replaying it with digest verification, not from the resolver version alone. This is portable dependency resolution, not a promise of byte-identical environments on every platform.

The graph-free v1 object validates recorded entries and authored root coverage; it cannot independently infer a missing transitive dependency. The pinned resolver supplies that complete set. Native resolver-adoption smoke tests check known conditional dependencies, and parser tests check their preservation; neither is a general proof of transitive closure from the serialized object.

requirements.txt, pyproject.toml, Poetry and user uv lockfiles are not alternate sources of truth. AgentPM generates its own isolated temporary resolver inputs from agent.json; it does not require converting your project to uv.

Managed Resolver#

AgentPM pins uv 0.13.5. No resolver download happens for Tools without declared dependencies. On first resolution, AgentPM downloads the approved standalone binary through the Registry's existing storage, verifies its compiled-in SHA-256, checks its exact version, and caches it outside the project. The cache uses the OS per-user AgentPM cache directory under runtimes/uv/0.13.5/<target>/. Every later execution checks its version again; managed copies also have their digest checked. AgentPM never searches PATH for uv. The override must name an existing file; relative paths use the current directory, not PATH lookup.

Resolver downloads honor standard HTTP/HTTPS proxy settings and use explicit connection and total request deadlines. This differs intentionally from optional CLI telemetry, which does not inherit proxies. Unsupported platforms fail before any resolver download and name supported targets and the override.

For airgapped, enterprise or preprovisioned CI environments, supply the exact pin:

export AGENTPM_UV_PATH=/opt/company/uv-0.13.5/uv
agentpm publish --dry-run

On Windows, point the variable to uv.exe. A different version is an error, not a warning; the override does not adopt whatever uv an image happens to contain. It avoids resolver acquisition, not the dependency index access needed for a fresh resolution. No resolver key or new website configuration is required.

Network/proxy failure, binary digest mismatch, override version mismatch, unsupported target and dependency-resolution failure have distinct messages. An HTTP 403/404 from the Registry or object storage instead reports that the resolver version/target is not mirrored or is inaccessible. A 404 can also mean the resolver route is absent from the deployed API build. Check route deployment, the mirrored object and storage permissions, rather than treating it as a proxy failure. Other HTTP service failures are also separate from transport failures. For maintainers, resolver mirror ingestion and permanent retention requirements are recorded in app/tools/domain/tools/RESOLVER_STORAGE.md in the Registry repo.

Portable resolution shape#

agent.json expresses author intent. agent.lock records the resolved portable state; .agentpm/ contains the consumer's selected artifact and local environment. One logical package key, such as tool:@your-namespace/your-tool@0.1.0, represents all targets. Do not create target-qualified package keys or edit generated locks. The CLI currently rejects unknown lock fields as well as unsupported future versions; it fails without rewriting that state. Read-only SDK metadata loading supports additive fields in supported v2/v3/v4 locks, but does not make arbitrary future versions compatible.

AgentPM generates the following agentpm.python-resolution.v1 shape. The digest below is illustrative; do not hand-author a resolution from this example:

{
  "type": "agentpm.python-resolution.v1",
  "python": { "requires": ">=3.11" },
  "requirements": ["example-library==1.0.0"],
  "packages": [
    {
      "name": "example-library",
      "version": "1.0.0",
      "marker": "python_version >= '3.11'",
      "hashes": ["sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
    }
  ]
}

The real object includes every resolved distribution, exact versions, optional conditional PEP 508 markers and nonempty sets of distribution SHA-256 digests. Names are normalized; requirements, packages and hash arrays have deterministic ordering. It locks distributions and conditional branches, not a publisher's selected wheel filename, architecture, interpreter path or virtualenv. The consumer selects a compatible wheel from that verified set. Its digest uses RFC 8785/JCS canonical JSON, as explained in release integrity.

Migrate a vendored Python Tool#

Existing _vendor Tools remain valid. There is no forced republish, and an old version keeps its legacy/unknown compatibility and original signed bytes. Vendoring is a legacy/manual dependency strategy: copying native libraries from one workstation can make an otherwise portable Tool unusable on other platforms.

To migrate an upcoming version:

  1. Bump agent.json.version; published versions are immutable.
  2. Declare Python requirements in runtime.dependencies and keep the minimum runtime.version accurate.
  3. Remove the old vendored distribution directories from the new payload and remove code that prepends them to Python's import path. Keep intentional first-party source/data listed in files. AgentPM does not delete bundled files merely because their packages are declared as dependencies.
  4. Run agentpm publish --dry-run --refresh-python, review the generated lock, and commit the manifest, source and lock.
  5. Publish the new version with an explicit namespace, then install and run it in a clean consumer. Test every supported platform where the Tool's behavior or bundled native content differs. Use the CI matrix for native payloads.

Consumers upgrade with agentpm install @your-namespace/your-tool@NEW_VERSION; the CLI updates the manifest/lock/install state. Do not lower the lock version, copy dependencies into global Python or edit .agentpm/ to simulate migration. Python and Node SDK 0.1.17+ use CLI 0.1.43+ for every Tool call, including legacy Tools; upgrading the CLI alone does not upgrade the SDK. See Python SDK and Node SDK.

Networks, proxies and preprovisioned hosts#

Allow HTTPS access to the selected Registry (the official origin is api.agentpackagemanager.com), its presigned object-storage URLs, and the Python index/distribution hosts used by the locked packages. The default PyPI flow uses pypi.org and files.pythonhosted.org. Resolver and package objects use the Registry's configured S3 host; use the host in the returned URLs rather than assuming a fixed bucket endpoint. GitHub access is not needed for a runtime resolver acquisition. Standard HTTP_PROXY, HTTPS_PROXY and NO_PROXY settings apply to required transfers.

Resolver downloads are shared across projects in these per-user cache locations:

PlatformResolver directory
macOS~/Library/Caches/com.agentpm.AgentPM/runtimes/uv/0.13.5/<target>/
Linux${XDG_CACHE_HOME:-~/.cache}/agentpm/runtimes/uv/0.13.5/<target>/
Windows%LOCALAPPDATA%\agentpm\AgentPM\cache\runtimes\uv\0.13.5\<target>\

The supported resolver/CLI targets are aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu and x86_64-pc-windows-msvc. The released Linux CLI 0.1.43 requires glibc 2.39 or newer. Linux arm64 and musl hosts are unsupported because AgentPM does not ship CLI releases for them; this is not a limitation of upstream uv.

AGENTPM_UV_PATH bypasses resolver download only when the provided binary reports the exact pinned version. A fully offline install also needs already-available AgentPM payloads and every required compatible locked wheel; this override alone does not make a fresh PyPI resolution/install airgapped. Preprovision and verify those inputs before disconnecting, or use an accessible managed package mirror.