Skip to main content

Adapter library to make Dapr Agents compatible with Open Agent Spec

Project description

dapr-agents-oas-adapter

Bidirectional conversion between Open Agent Spec (OAS) and Dapr Agents.

Python 3.12+ License CI

Overview

dapr-agents-oas-adapter enables seamless interoperability between Open Agent Spec (OAS) specifications and Dapr Agents. Import OAS specifications to create executable Dapr Agents and workflows, or export existing Dapr Agents to portable OAS format.

Key Features

  • Bidirectional conversion -- Import OAS specs into Dapr Agents and export back to OAS
  • Schema validation -- Validate OAS specifications before conversion with detailed error reports
  • Caching -- In-memory cache with configurable TTL for repeated operations
  • Async support -- Non-blocking loader for high-throughput applications
  • Structured logging -- Built-in structlog integration for observability

Installation

pip install dapr-agents-oas-adapter

Or with uv:

uv add dapr-agents-oas-adapter

Quick Start

Load an OAS spec and create a Dapr Agent

from dapr_agents_oas_adapter import DaprAgentSpecLoader

loader = DaprAgentSpecLoader()
config = loader.load_yaml(oas_yaml)
agent = loader.create_agent(config)

Export a Dapr Agent to OAS format

from dapr_agents_oas_adapter import DaprAgentSpecExporter

exporter = DaprAgentSpecExporter()
oas_dict = exporter.to_dict(config)

Validate before conversion

from dapr_agents_oas_adapter import StrictLoader

loader = StrictLoader()
try:
    config = loader.load_dict(oas_dict)
except OASSchemaValidationError as e:
    print(f"Validation failed: {e.issues}")

Component Mapping

OAS Component Dapr Agents
Agent AssistantAgent / ReActAgent
Flow @workflow decorated function
LlmNode @task with LLM call
ToolNode @task with tool call
FlowNode ctx.call_child_workflow()
MapNode Fan-out with wf.when_all()
ControlFlowEdge Branch routing via from_branch

Running the Examples

Prerequisites

  • Dapr CLI installed and initialized
  • An OpenAI API key in examples/_shared/dapr/components/secrets/

Run an example

cd examples/from_oas/04-agent-based-workflows
dapr run -f dapr.yaml -- python app.py

Examples are organized in two directions:

  • examples/from_oas/ -- Import OAS specs to create Dapr Agents
  • examples/to_oas/ -- Export Dapr Agents to OAS format

Development

git clone https://github.com/heltondoria/dapr-agents-oas-adapter.git
cd dapr-agents-oas-adapter
uv sync --all-groups
uv run pytest                          # Run tests
uv run ruff check .                    # Lint
uv run ruff format --check .           # Check formatting
uv run ty check                        # Type check
uv run codespell .                     # Spell check
uv run vulture .                       # Dead code detection

Tests require 90% coverage:

uv run pytest --cov=src/dapr_agents_oas_adapter --cov-fail-under=90

Documentation

Full documentation is available at heltondoria.github.io/dapr-agents-oas-adapter.

To serve locally:

uv run mkdocs serve

License

Apache License 2.0 -- see LICENSE for details.

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

dapr_agents_oas_adapter-0.8.0.tar.gz (54.9 kB view details)

Uploaded Source

Built Distribution

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

dapr_agents_oas_adapter-0.8.0-py3-none-any.whl (65.4 kB view details)

Uploaded Python 3

File details

Details for the file dapr_agents_oas_adapter-0.8.0.tar.gz.

File metadata

  • Download URL: dapr_agents_oas_adapter-0.8.0.tar.gz
  • Upload date:
  • Size: 54.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dapr_agents_oas_adapter-0.8.0.tar.gz
Algorithm Hash digest
SHA256 6cfc61433272587a5cf45ed5677bfc6d97a18c6e424c7a77319927a207ea9b76
MD5 20014ee3348dae422e5a7b43805b4107
BLAKE2b-256 176bdc121bdbd7f1bb9f1d5a3458898915b01ac0daa72427f045145755b69707

See more details on using hashes here.

Provenance

The following attestation bundles were made for dapr_agents_oas_adapter-0.8.0.tar.gz:

Publisher: publish.yml on heltondoria/dapr-agents-oas-adapter

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

File details

Details for the file dapr_agents_oas_adapter-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dapr_agents_oas_adapter-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1160f5dda430a51fa4d9533efc9fc73615c0e7c9bc137d961cb4575c8d79f23
MD5 24c64bc1c27b53250d73b38851df9418
BLAKE2b-256 b5fcfcb4f8efa317495e113fdf772b9755279124345ce7c93920265fc6a23e5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dapr_agents_oas_adapter-0.8.0-py3-none-any.whl:

Publisher: publish.yml on heltondoria/dapr-agents-oas-adapter

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