Skip to main content

DACP - Delcarative Agent Communication Protocol

A Python library for managing LLM/agent communications and tool function calls following the OAS Open Agent Specification.

Installation

pip install -e .

Quick Start

import dacp

# Register a custom tool
def my_custom_tool(param1: str, param2: int) -> dict:
    return {"result": f"Processed {param1} with {param2}"}

dacp.register_tool("my_custom_tool", my_custom_tool)

# Call an LLM
response = dacp.call_llm("What is the weather like today?")

# Parse agent response
parsed = dacp.parse_agent_response(response)

# Check if it's a tool request
if dacp.is_tool_request(parsed):
    tool_name, args = dacp.get_tool_request(parsed)
    result = dacp.run_tool(tool_name, args)
    tool_response = dacp.wrap_tool_result(tool_name, result)

Features

  • Tool Registry: Register and manage custom tools for LLM agents
  • LLM Integration: Built-in support for OpenAI models (extensible)
  • Protocol Parsing: Parse and validate agent responses
  • Tool Execution: Safe execution of registered tools
  • OAS Compliance: Follows Open Agent Specification standards

API Reference

Tools

  • register_tool(tool_id: str, func): Register a new tool
  • run_tool(tool_id: str, args: Dict) -> dict: Execute a registered tool
  • TOOL_REGISTRY: Access the current tool registry

LLM

  • call_llm(prompt: str, model: str = "gpt-4") -> str: Call an LLM with a prompt

Protocol

  • parse_agent_response(response: str | dict) -> dict: Parse agent response
  • is_tool_request(msg: dict) -> bool: Check if message is a tool request
  • get_tool_request(msg: dict) -> tuple[str, dict]: Extract tool request details
  • wrap_tool_result(name: str, result: dict) -> dict: Wrap tool result for agent
  • is_final_response(msg: dict) -> bool: Check if message is a final response
  • get_final_response(msg: dict) -> dict: Extract final response

Development

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Format code
black .

# Lint code
flake8

License

MIT License

Metadata

Release files for dacp 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 dacp 0.1.0
File Size Uploaded Provenance Actions
dacp-0.1.0.tar.gz 7.1 kB Without provenance Details for dacp-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 12.5 kB

Release files / dacp-0.1.0.tar.gz

Download URL dacp-0.1.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b16d446cd3f78d4bf771f61d61ddbd66e997906f9d2a86b4b041750593568f97
BLAKE2b-256 checksum
How to use checksums
2a35445048584d042765e157cfd8a4877df4682cca45a72a8ea079c76657bc6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

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

Download URL dacp-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81721bdc700b2acb826c6d31e33725500c9332d81c6f5ce57fe36e83a61bfa86
BLAKE2b-256 checksum
How to use checksums
405b7bae799d1fcb6dd1fb0a3730bc1271280434d614c81ca163b93256e902ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Security for dacp 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.

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.

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