Skip to main content

Python SDK for portable AI agent evaluations with outputs, tool calls, and audit context.

Project description

ECP Python SDK

Python SDK for building agents that comply with the Evaluation Context Protocol (ECP).

ECP is a vendor-neutral protocol for testing agent outputs, tool calls, and evaluator-visible audit context across frameworks, models, eval platforms, and CI systems.

Install

pip install "ecp-sdk==0.3.1"

Framework extras:

pip install "ecp-sdk[langchain]==0.3.1"
pip install "ecp-sdk[crewai]==0.3.1"
pip install "ecp-sdk[llamaindex]==0.3.1"
pip install "ecp-sdk[pydanticai]==0.3.1"

Usage

from ecp import Result, agent, on_step, serve


@agent(name="MyAgent")
class MyAgent:
    @on_step
    def step(self, user_input: str):
        return Result(
            public_output=f"Echo: {user_input}",
            evaluation_context="Echoed the input for evaluation.",
            tool_calls=[{"name": "echo", "arguments": {"text": user_input}}],
        )


if __name__ == "__main__":
    serve(MyAgent())

evaluation_context is the preferred field for evaluator-safe audit evidence. private_thought is still accepted as a deprecated compatibility alias.

Async lifecycle hooks

@on_step and @on_reset may be synchronous functions or async def coroutines. The SDK awaits async hooks on one persistent event loop, so loop-bound clients and other async resources can be reused across requests.

import asyncio

from ecp import Result, agent, on_reset, on_step, serve


@agent(name="AsyncAgent")
class AsyncAgent:
    @on_step
    async def step(self, user_input: str) -> Result:
        await asyncio.sleep(0.01)
        return Result(public_output=f"Processed: {user_input}")

    @on_reset
    async def reset(self) -> None:
        await asyncio.sleep(0)


if __name__ == "__main__":
    serve(AsyncAgent())

The same hooks work with serve_http(...). See examples/async_python_demo for a runnable agent that supports either transport.

Streamable HTTP

Agents can also run as an ECP Streamable HTTP server:

if __name__ == "__main__":
    ecp.serve_http(MyAgent(), host="127.0.0.1", port=8765, path="/ecp")

The endpoint accepts JSON-RPC POST requests at /ecp. It returns JSON for requests, 202 Accepted for notifications, and 405 Method Not Allowed for GET SSE streams until ECP defines server-initiated messages.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ecp_sdk-0.5.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ecp_sdk-0.5.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file ecp_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: ecp_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ecp_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d937825572558f31793b920c35bba690db21069df3e06764bbdcbf6693f7f6b9
MD5 a71bda752dd5fdd55bf02655df08f884
BLAKE2b-256 fc8fb4dd23a3cb095c92c15b9c8b366c409f1f8fc5e21dd0543d105c8cc0c621

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecp_sdk-0.5.0.tar.gz:

Publisher: release.yml on evaluation-context-protocol/ecp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ecp_sdk-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ecp_sdk-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ecp_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87f539817edabd4266094e19533dd52c274db21ff13d88af1223998cfad0dd90
MD5 4f2592ff7b033a0d72a8a40466d5d329
BLAKE2b-256 c192bc98a4122f4c0289d706d338437abee73802f958b0409b1867a0d209619a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ecp_sdk-0.5.0-py3-none-any.whl:

Publisher: release.yml on evaluation-context-protocol/ecp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page