Agent Communication Protocol (ACP) - A standardized protocol for multi-agent system communication
Project description
ACP - Agent Communication Protocol
A standardized, enforceable protocol for communication between AI agents in multi-agent systems.
Why ACP?
Multi-agent systems today suffer from:
- Unstructured Communication: Agents pass free-form text or inconsistent JSON with no semantic guarantees
- No Confidence Modeling: Agents cannot express uncertainty or enable weighted consensus
- Constraint Violations: No formal way to specify or enforce constraints
- Trust Failures: No agent reputation system or capability verification
- Debugging Impossibility: Post-mortem analysis requires archaeology
ACP solves these problems with:
- Standardized message schema with Pydantic validation
- First-class confidence with calibration tracking
- Enforceable constraints with validation hooks
- Trust levels with automatic degradation/upgrade
- Structured intents for semantic routing
Installation
pip install acp-protocol
With LangChain integration:
pip install acp-protocol[langchain]
For development:
pip install acp-protocol[dev]
Quick Start
Creating Messages
from acp import ACPMessage, Intent, Constraints, Context
# Create a delegation message
message = ACPMessage(
sender_id="coordinator_agent",
recipient_id="summarizer_agent",
intent=Intent.DELEGATE,
content={
"task": "summarize_document",
"document_id": "doc_123",
},
confidence=0.87,
constraints=Constraints(
max_tokens=800,
deadline_ms=5000,
),
context=Context(
domain="legal",
urgency="high",
),
)
# Create a response
response = message.create_report(
sender_id="summarizer_agent",
status="completed",
confidence=0.92,
result={"summary": "The document discusses..."},
)
Validating Messages
from acp import ACPValidator
validator = ACPValidator(strict_mode=True)
# Validate and raise on error
validated_message = validator.validate_or_raise(message)
# Or get detailed result
result = validator.validate(message)
if not result.valid:
for error in result.errors:
print(f"Error: {error}")
Confidence Calibration
from acp import Calibrator
calibrator = Calibrator()
# Record outcomes after tasks complete
calibrator.record_outcome("agent_01", claimed_confidence=0.90, success=True)
calibrator.record_outcome("agent_01", claimed_confidence=0.85, success=False)
# Adjust future confidence claims based on history
adjusted = calibrator.adjust_confidence("agent_01", claimed_confidence=0.90)
# Returns lower value if agent is historically overconfident
# Get calibration metrics
metrics = calibrator.get_metrics("agent_01")
print(f"Reliability: {metrics.reliability_score:.2%}")
print(f"ECE: {metrics.expected_calibration_error:.4f}")
Trust Management
from acp import TrustManager, TrustLevel
trust_manager = TrustManager()
# Record successes/failures
trust_manager.record_success("agent_01")
trust_manager.record_failure("agent_02", "Task timeout")
# Check trust level
level = trust_manager.get_trust_level("agent_01")
print(f"Trust level: {level.value}") # "trusted"
# Block problematic agents
trust_manager.block_agent("bad_agent", "Malicious behavior")
Routing
from acp import Router, AgentCapability, Calibrator, TrustManager
router = Router()
calibrator = Calibrator()
trust_manager = TrustManager()
# Register agents with capabilities
router.register_agent(AgentCapability(
agent_id="summarizer_01",
capabilities={"summarization", "text_processing"},
min_deadline_ms=1000,
max_tokens=2000,
))
# Route to best agent
best_agent = router.route(
message,
calibrator=calibrator,
trust_manager=trust_manager,
required_capabilities={"summarization"},
)
LangChain Integration
from acp.adapters import ACPLangChainAdapter
from acp import Intent
adapter = ACPLangChainAdapter(
agent_id="langchain_agent",
default_domain="general",
)
# Create delegation
delegation = adapter.create_delegation(
task="Summarize this document",
recipient_id="summarizer",
confidence=0.85,
)
# Wrap LangChain output as ACP message
response = adapter.wrap_langchain_response(
langchain_output=chain_result,
recipient_id="coordinator",
intent=Intent.REPORT,
confidence=0.90,
)
# Unwrap ACP message for LangChain
chain_input = adapter.create_chain_input(incoming_message)
Core Concepts
Intents
ACP defines 10 semantic intents:
| Intent | Description | Required Content |
|---|---|---|
REQUEST |
Ask for information | content.query |
DELEGATE |
Assign a task | content.task |
VERIFY |
Check correctness | content.target_message_id |
CHALLENGE |
Dispute a claim | content.reason |
PROPOSE |
Suggest action | content.proposal |
ACCEPT |
Agree to proposal | parent_message_id |
REJECT |
Decline proposal | content.reason |
ESCALATE |
Raise to supervisor | content.reason |
REPORT |
Status update | content.status |
TERMINATE |
End interaction | content.reason |
Trust Levels
| Level | Description | Score |
|---|---|---|
VERIFIED |
Cryptographically proven | 1.0 |
TRUSTED |
Good historical performance | 0.8 |
NEUTRAL |
Unknown/new agent | 0.5 |
SUSPICIOUS |
Warning flags present | 0.2 |
BLOCKED |
Do not interact | 0.0 |
Constraints
Constraints(
max_tokens=800, # Maximum response length
deadline_ms=5000, # Response deadline (≥100ms)
quality_threshold=0.85, # Minimum quality score
max_cost_usd=0.50, # Budget limit
require_sources=True, # Must cite sources
allowed_tools=["search", "calculator"], # Permitted tools
)
Confidence
- Range:
[0.01, 0.99](no perfect certainty allowed) - Optional uncertainty bounds:
(lower, upper)tuple - Calibration system tracks accuracy over time
API Reference
Models
ACPMessage- Core message structureIntent- Message intent enumTrustLevel- Trust level enumConstraints- Task constraintsContext- Message context
Validation
ACPValidator- Multi-layer message validatorValidationResult- Validation outcome
Calibration
Calibrator- Confidence calibration systemCalibrationMetrics- Agent calibration data
Trust
TrustManager- Agent trust managementTrustEvent- Trust change record
Routing
Router- Capability-based routingAgentCapability- Agent capability description
Adapters
BaseACPAdapter- Abstract adapter base classACPLangChainAdapter- LangChain integration
Converters
UnstructuredToACPConverter- Legacy text to ACP
Exceptions
ACPError- Base exceptionValidationError- Validation failuresIntentValidationError- Intent/content mismatchConstraintValidationError- Invalid constraintsTemporalValidationError- Timestamp/deadline issuesTrustValidationError- Trust violationsRoutingError- No suitable agent found
Examples
See the examples/ directory:
basic_usage.py- Fundamental operationsdelegation_flow.py- Multi-agent workflowlangchain_example.py- LangChain integration
Run examples:
python examples/basic_usage.py
python examples/delegation_flow.py
python examples/langchain_example.py
Testing
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# With coverage
pytest --cov=src/acp --cov-report=term-missing
Protocol Version
This library implements ACP v1.0.0.
Protocol version is included in every message:
message.protocol_version # "1.0.0"
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Submit a pull request
License
MIT License - see LICENSE for details.
Acknowledgments
Based on the ACP v1.0 Specification by the ACP Working Group.
Links
Project details
Release history Release notifications | RSS feed
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 acp_protocol-1.0.0.tar.gz.
File metadata
- Download URL: acp_protocol-1.0.0.tar.gz
- Upload date:
- Size: 44.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02213dac3767b1bf37c07b509b3a732003d7848c0638871a4ff5cafc14bc3a27
|
|
| MD5 |
6e7d6af2b6bde279708adb8535062883
|
|
| BLAKE2b-256 |
60194abd376d692c933bd4fe104a55647c9e6331be4b193bb1e501f45fced5e8
|
File details
Details for the file acp_protocol-1.0.0-py3-none-any.whl.
File metadata
- Download URL: acp_protocol-1.0.0-py3-none-any.whl
- Upload date:
- Size: 33.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
526ae73afb81513f7a37934dab6dd91135fd13df6cb2bce4ed43dd5641c94c14
|
|
| MD5 |
6a157acf2294390e3376055a52a21182
|
|
| BLAKE2b-256 |
9ce6fb140af17abd9857ce482760c6e48206bbe18eea577f55e9511e8963e424
|