Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

AgentField Python SDK

The AgentField SDK provides a production-ready Python interface for registering agents, executing workflows, and integrating with the AgentField control plane.

Installation

pip install agentfield

To work on the SDK locally:

git clone https://github.com/Agent-Field/agentfield.git
cd agentfield/sdk/python
python -m pip install -e .[dev]

Quick Start

from agentfield import Agent

agent = Agent(
    node_id="example-agent",
    agentfield_server="http://localhost:8080",
    dev_mode=True,
)

@agent.reasoner()
async def summarize(text: str) -> dict:
    result = await agent.ai(
        prompt=f"Summarize: {text}",
        response_model={"summary": "string", "tone": "string"},
    )
    return result

if __name__ == "__main__":
    agent.serve(port=8001)

AI Tool Calling

Let LLMs automatically discover and invoke agent capabilities across your system:

from agentfield import Agent, AIConfig, ToolCallConfig

app = Agent(
    node_id="orchestrator",
    agentfield_server="http://localhost:8080",
    ai_config=AIConfig(model="openai/gpt-4o-mini"),
)

@app.reasoner()
async def ask_with_tools(question: str) -> dict:
    # Auto-discover all tools and let the LLM use them
    result = await app.ai(
        system="You are a helpful assistant.",
        user=question,
        tools="discover",
    )
    return {"answer": str(result), "trace": result.trace}

# Filter by tags, limit turns, use lazy hydration
result = await app.ai(
    user="Get weather for Tokyo",
    tools=ToolCallConfig(
        tags=["weather"],
        schema_hydration="lazy",  # Reduces token usage for large catalogs
        max_turns=5,
        max_tool_calls=10,
    ),
)

Key features:

  • tools="discover" — Auto-discover all capabilities from the control plane
  • ToolCallConfig — Filter by tags, agent IDs, health status
  • Lazy hydration — Send only tool names/descriptions first, hydrate schemas on demand
  • Guardrails — max_turns and max_tool_calls prevent runaway loops
  • Observability — result.trace tracks every tool call with latency

See examples/python_agent_nodes/tool_calling/ for a complete orchestrator + worker example.

Human-in-the-Loop Approvals

The Python SDK provides a first-class waiting state for pausing agent execution mid-reasoner and waiting for human approval:

from agentfield import Agent, ApprovalResult

app = Agent(node_id="reviewer", agentfield_server="http://localhost:8080")

@app.reasoner()
async def deploy(environment: str) -> dict:
    plan = await app.ai(f"Create deployment plan for {environment}")

    # Pause execution and wait for human approval
    result: ApprovalResult = await app.pause(
        approval_request_id="req-abc123",
        expires_in_hours=24,
        timeout=3600,
    )

    if result.approved:
        return {"status": "deploying", "plan": str(plan)}
    elif result.changes_requested:
        return {"status": "revising", "feedback": result.feedback}
    else:
        return {"status": result.decision}

Two API levels:

  • High-level: app.pause() blocks the reasoner until approval resolves, with automatic webhook registration
  • Low-level: client.request_approval(), client.get_approval_status(), client.wait_for_approval() for fine-grained control

See examples/python_agent_nodes/waiting_state/ for a complete working example.

See docs/DEVELOPMENT.md for instructions on wiring agents to the control plane.

Testing

./scripts/run_pytest.sh

To run coverage locally:

./scripts/run_pytest.sh --cov=agentfield --cov-report=term-missing

The wrapper sets a private PYTEST_DEBUG_TEMPROOT automatically so local runs and CI do not rely on pytest's predictable default temp directory layout.

License

Distributed under the Apache 2.0 License. See the project root LICENSE for details.

Metadata

Release files for agentfield 0.1.85rc10

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

Source distribution (sdist)

Source distribution for agentfield 0.1.85rc10
File Size Uploaded Provenance Actions
agentfield-0.1.85rc10.tar.gz 235.5 kB Without provenance Details for agentfield-0.1.85rc10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentfield 0.1.85rc10
File Interpreter ABI Platform Actions
agentfield-0.1.85rc10-py3-none-any.whl Python 3 none any Details for agentfield-0.1.85rc10-py3-none-any.whl

Total release size: 497.4 kB

Release files / agentfield-0.1.85rc10.tar.gz

Download URL agentfield-0.1.85rc10.tar.gz
Size 235.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5273c51f9afd56506e7dcefa7d2059784cae7387b83742f74dee4143106a93bb
BLAKE2b-256 checksum
How to use checksums
70b15ad1daa759de992112ac99013085aa4dd7774b5efaf0b0c0d23caa388ccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / agentfield-0.1.85rc10-py3-none-any.whl

Download URL agentfield-0.1.85rc10-py3-none-any.whl
Size 261.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
368cca2ed71878735be43de95954a78977b9768517418b6bade6c73c96ccd41e
BLAKE2b-256 checksum
How to use checksums
975aa991d8addb897067f69e00f528fbc1824421a1c7f844674a88466b1491f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for agentfield 0.1.85rc10

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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
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