Skip to main content

pyagent-dns

A standalone PyAgent package that separates naming from authorization for multi-agent systems with signed records and attenuated authority graphs.

License: MIT Python 3.11+

Architecture Extension: 🛡️ Naming & Authorization A local-first, spec-driven authorization plane for agents, tools, providers, data, and approvers. Resolves names to cryptographically signed records and verifies authority graphs before consequential actions run. Part of the PyAgent ecosystem: pip install pyagent-dns.

Disambiguation

pyagent-dns is:

  • Not AgentDNS: It does not implement global decentralized root servers, cryptocurrency settlement, or billing tokens.
  • Not OWASP ANS or IETF DAWN: It does not require public PKI certificate authorities or internet-wide DID federation.
  • What it is: A local-first, in-repo implementation of the separation those standards leave open: records describe, grants decide.

Install

pip install pyagent-dns                        # Core (records, Ed25519 signing, registry, graph, middleware)
pip install "pyagent-dns[trace]"               # + PyAgent trace event bus integration
pip install "pyagent-dns[context]"             # + PyAgent context sensitivity and redaction mapping
pip install "pyagent-dns[blueprint]"           # + PyAgent blueprint extension loader
pip install "pyagent-dns[all]"                 # All optional integrations

Depends on: pyagent-patterns, pydantic, pyyaml, cryptography.

Why Two Planes?

In conventional agent architectures, discovering a tool or endpoint implies having permission to call it. This ambient authority creates the confused deputy problem: a high-clearance supervisor delegates to a subagent, which then invokes high-risk tools with no boundary checks.

pyagent-dns splits this into two independent planes:

  1. Naming Plane: Cryptographically signed NameRecord objects declare capabilities, endpoints, data classes, and schema hashes.
  2. Authorization Plane: Grant declarations evaluate whether a principal chain may execute a specific action on a capability for a designated purpose under strict limits.

Quickstart

Every Python block below is executed by the test suite, in order, so this page cannot drift from the API.

1. Sign a NameRecord

from pyagent_dns.records import Identity, NameRecord, RecordKind
from pyagent_dns.signing import (
    TrustedKey,
    TrustedKeys,
    fingerprint_of_public_key,
    generate_keypair,
    load_private_key,
    sign_record,
)

# Writes private_key.pem (mode 0600) and public_key.pem. Never overwrites an existing key.
private_path, public_path = generate_keypair(".keys")
public_key = public_path.read_text()
fingerprint = fingerprint_of_public_key(public_key)

record = NameRecord(
    name="portfolio-data.reader",
    kind=RecordKind.TOOL,
    version="1.0.0",
    endpoint="https://internal.bank/tools/portfolio",
    identity=Identity(
        public_key_fingerprint=fingerprint,
        public_key=public_key,
        signed_by="security_team",
    ),
    schema_hash="sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    capabilities=("read_positions", "read_holdings"),
    data_classes=("internal",),
    owner="wealth_platform_team",
)
signed_record = sign_record(record, load_private_key(private_path))

2. Register it and resolve it

A record is only as trustworthy as the keys you trust. The registry verifies against the TrustedKeys you give it, never against a key carried inside the record.

from pyagent_dns.registry import NameRegistry
from pyagent_dns.resolver import Resolver

trusted = TrustedKeys([TrustedKey("security_team", fingerprint, public_key)])
registry = NameRegistry(trusted)
registry.register(signed_record)

resolver = Resolver(registry)
resolution = resolver.resolve("portfolio-data.reader")
print(resolution.verification)  # verified
print(resolution.from_cache)  # False

Resolution is a local lookup and a signature check. It never connects to the record's endpoint.

3. Evaluate a grant

Resolving a name grants nothing. Permission comes only from a Grant.

from pyagent_dns.authority import (
    Action,
    AuthorityGraph,
    CallContext,
    Grant,
    Limits,
    ResourceSelector,
)

graph = AuthorityGraph(registry)
graph.add_grant(
    Grant(
        grant_id="grant-001",
        principal="analyst_agent",
        action=Action.CALL,
        capability="portfolio-data.reader",
        resource=ResourceSelector(data_classes=("internal",)),
        purpose="portfolio_review",
        limits=Limits(max_records_per_call=500),
    )
)

decision = graph.authorize(
    ["analyst_agent"],
    Action.CALL,
    "portfolio-data.reader",
    ResourceSelector(),
    CallContext(purpose="portfolio_review", records_requested=100),
    resolution,
)
print(decision.allowed, decision.reason_code)  # True GRANT_FOUND

4. Guard ReAct tools

from pyagent_dns.middleware import DnsMiddleware

middleware = DnsMiddleware(resolver, graph)
tools = {"portfolio-data.reader": lambda query: "positions: AAPL, GOOG"}

analyst_tools = middleware.guard_tools(
    tools, principal_chain=["analyst_agent"], purpose="portfolio_review"
)
print(analyst_tools["portfolio-data.reader"]("account_123"))  # positions: AAPL, GOOG

stranger_tools = middleware.guard_tools(
    tools, principal_chain=["stranger"], purpose="portfolio_review"
)
print(stranger_tools["portfolio-data.reader"]("account_123"))  # DENIED [NO_GRANT] ...

A denied tool is never called. The model receives the DENIED [CODE] reason string as its observation, so it can replan. Every decision is kept in middleware.decisions.


Downward-Only Delegation (Attenuation)

A grant can be delegated to a subagent, but authority can only narrow, never widen:

from pyagent_dns.authority import AttenuationError, DelegationTerms, GrantScope

graph.add_grant(
    Grant(
        grant_id="grant-lead",
        principal="lead_agent",
        action=Action.CALL,
        capability="portfolio-data.reader",
        resource=ResourceSelector(data_classes=("internal",)),
        purpose="portfolio_review",
        limits=Limits(max_records_per_call=500),
        delegation=DelegationTerms(allowed=True),
    )
)

narrower = graph.delegate(
    "grant-lead",
    delegate_principal="subagent_researcher",
    scope=GrantScope(limits=Limits(max_records_per_call=100)),
)
print(narrower.grant.limits.max_records_per_call)  # 100

try:
    graph.delegate(
        "grant-lead",
        delegate_principal="subagent_researcher",
        scope=GrantScope(limits=Limits(max_records_per_call=1000)),
    )
except AttenuationError as err:
    print(f"Refused widening on: {err.dimension}")  # limits.max_records_per_call

Known Limitations of v0.1

  1. ReAct Tool Call Surface: Because pyagent-patterns executes tools by text parsing in ReAct, tools accept a string input. Structured argument inspection and per-call numeric limits (records_requested, amount) are evaluated via authorize_call(), while guard_tools() hashes raw string input for approval bindings.
  2. Blueprint Spec Extension: Top-level x-pyagent:dns blocks are read directly from YAML via load_blueprint_dns(). They do not currently round-trip through pyagent-blueprint's BlueprintSpec parser.
  3. Local Resolution: Verification validates the authenticity and integrity of the NameRecord. It does not connect to remote endpoints or verify live workload identity at runtime.

Full Documentation

See pyagent.org for full API references, architecture guides, and cookbook examples.

The PyAgent ecosystem

PyAgent is a spec-driven architecture for orchestrating multi-agent systems. Each package is independent — install only what you need, or get everything with pip install pyagent-all.

Package What it gives you
pyagent-blueprint Declarative multi-agent blueprints — compile, validate, and diff agent systems from YAML
pyagent-patterns Reusable multi-agent design patterns — Supervisor, Pipeline, ReAct, and 15 more
pyagent-router Difficulty-aware model routing — cost-efficient model selection per task
pyagent-compress Token-efficient agent compression — inter-agent token budgets
pyagent-providers Multi-provider orchestration — fallback chains and capability negotiation
pyagent-context Stateful agent memory — trust-aware, three-tier context ledger
pyagent-trace Multi-agent observability & tracing — pattern-aware OpenTelemetry spans
pyagent-studio Agent control plane dashboard — live traces, cost, and governance
pyagent-dns Agent naming & authority graph — signed records and attenuated grants

Learn more: Design patterns · Cookbook · Get started

Metadata

Release files for pyagent-dns 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyagent-dns 0.1.0
File Size Uploaded Provenance Actions
pyagent_dns-0.1.0.tar.gz 77.5 kB With provenance Details for pyagent_dns-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyagent-dns 0.1.0
File Interpreter ABI Platform Actions
pyagent_dns-0.1.0-py3-none-any.whl Python 3 none any Details for pyagent_dns-0.1.0-py3-none-any.whl

Total release size: 122.6 kB

Release files / pyagent_dns-0.1.0.tar.gz

Download URL pyagent_dns-0.1.0.tar.gz
Size 77.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a8c8fa839973886bb259939a25d5ac863792abcfbaaf2061fafe2f03a8947ba3
BLAKE2b-256 checksum
How to use checksums
d75ea9eadf8569819b7a47dc632be5b8de81978e0e8df4cc5b8ece44d0785dc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / pyagent_dns-0.1.0-py3-none-any.whl

Download URL pyagent_dns-0.1.0-py3-none-any.whl
Size 45.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d18a03f16f406e516a830ca21281b5d51ce1c9775dfac8d4dea60e362acc2a0
BLAKE2b-256 checksum
How to use checksums
dc269be09507d2ff5576443e9c197804b729e35e22cce9e21b85e425c3ff8bd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for pyagent-dns 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyagent_dns-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page