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.9.0"
Framework extras:
pip install "ecp-sdk[langchain]==0.9.0"
pip install "ecp-sdk[crewai]==0.9.0"
pip install "ecp-sdk[llamaindex]==0.9.0"
pip install "ecp-sdk[pydanticai]==0.9.0"
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.
Testing Your Own Adapter
The bundled adaptors are a convenience, not a requirement - any framework works
if you return a Result. If you write your own, ecp.testing is the same
harness the built-in adaptors use, so you can pin its behaviour without
installing your framework in CI or holding API keys:
from ecp.testing import record_fixture, replay
# Once, with the framework installed and credentials set:
fixture = record_fixture("crewai", crew, "What is 15 multiplied by 8?")
fixture.save("tests/fixtures/crew_calculator.json")
# Then in CI, offline:
from ecp.testing import AdapterFixture, diff_expected
assert diff_expected(AdapterFixture.load("tests/fixtures/crew_calculator.json")) == []
record_fixture captures the framework's real response object and the Result
your adapter produced from it. replay re-runs the adapter against that capture.
When a framework reshapes its internals, your tool_calls would otherwise go
quietly empty and every tool_usage grader would fail as if the agent had
regressed - this turns that into a clear test failure.
Links
- Documentation: https://evaluationcontextprotocol.io/
- Repository: https://github.com/evaluation-context-protocol/ecp
- Issues: https://github.com/evaluation-context-protocol/ecp/issues
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ecp_sdk-0.9.0.tar.gz.
File metadata
- Download URL: ecp_sdk-0.9.0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d81a46b3f3e6decfd3285d015f9e7899c6dfbf48e957484aa98361eb63fac6cd
|
|
| MD5 |
781cf9f1f87d323a1342260e180bf6aa
|
|
| BLAKE2b-256 |
872385d38d508c5d937d5612e7f5d314acae7e98a2d92e970316b8e544b4a6ce
|
Provenance
The following attestation bundles were made for ecp_sdk-0.9.0.tar.gz:
Publisher:
release.yml on evaluation-context-protocol/ecp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ecp_sdk-0.9.0.tar.gz -
Subject digest:
d81a46b3f3e6decfd3285d015f9e7899c6dfbf48e957484aa98361eb63fac6cd - Sigstore transparency entry: 2527178450
- Sigstore integration time:
-
Permalink:
evaluation-context-protocol/ecp@6dc3a6e07fff3166869cc803879c38fe60e01bb7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/evaluation-context-protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6dc3a6e07fff3166869cc803879c38fe60e01bb7 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file ecp_sdk-0.9.0-py3-none-any.whl.
File metadata
- Download URL: ecp_sdk-0.9.0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
530d089592b78f42a6070cab2a095bed7785e4f0556fce4e597f3cce3b533d66
|
|
| MD5 |
aadb390a5db03c9b3f2a37861e57ba87
|
|
| BLAKE2b-256 |
06e201171555dd3bc4a66eead33883f30d9e4ec18621378e89e0d33f9b3dad7b
|
Provenance
The following attestation bundles were made for ecp_sdk-0.9.0-py3-none-any.whl:
Publisher:
release.yml on evaluation-context-protocol/ecp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ecp_sdk-0.9.0-py3-none-any.whl -
Subject digest:
530d089592b78f42a6070cab2a095bed7785e4f0556fce4e597f3cce3b533d66 - Sigstore transparency entry: 2527179605
- Sigstore integration time:
-
Permalink:
evaluation-context-protocol/ecp@6dc3a6e07fff3166869cc803879c38fe60e01bb7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/evaluation-context-protocol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6dc3a6e07fff3166869cc803879c38fe60e01bb7 -
Trigger Event:
pull_request
-
Statement type: