Metadata-Version: 2.4
Name: aiyoplane-microsoft-agent-framework
Version: 1.0.0
Summary: AEAP Composition Boundary Adapter for the Microsoft Agent Framework. Thin wrapper that attaches the Runtime Decision Point to agent middleware and workflow execution.
Author-email: "Aiyoplane, Inc." <rashon@aiyoplane.com>
License: Apache-2.0
Project-URL: Homepage, https://aiyoplane.com
Project-URL: Documentation, https://github.com/aiyoplane/microsoft-agent-framework-python
Project-URL: Repository, https://github.com/aiyoplane/microsoft-agent-framework-python
Project-URL: Issues, https://github.com/aiyoplane/microsoft-agent-framework-python/issues
Project-URL: Trust Surface, https://aiyoplane.com/trust
Project-URL: AEAP Specification, https://github.com/aiyoplane/aeap
Keywords: aiyo,aiyoplane,aeap,microsoft,agent-framework,autogen,semantic-kernel,authorization,runtime-decision-point,rdp,execution-receipt,composition-boundary,middleware,workflow,enterprise-agents
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: aiyoplane-mcp-authz>=1.0.1
Requires-Dist: agent-framework>=0.1.0
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-asyncio>=0.21; extra == "test"
Dynamic: license-file

# aiyoplane-microsoft-agent-framework

**AEAP Composition Boundary Adapter for the Microsoft Agent Framework.**

A thin wrapper that attaches the AEAP Runtime Decision Point (RDP) to the Microsoft Agent Framework's middleware chain and workflow nodes. Consequential actions produce independently verifiable Execution Receipts. The adapter composes with the framework's own middleware, telemetry, session, and tool machinery.

```bash
pip install aiyoplane-microsoft-agent-framework
```

## Why Microsoft Agent Framework

Microsoft's current Agent Framework — the successor to AutoGen and Semantic Kernel — explicitly includes **middleware for intercepting agent actions** as a first-class architectural primitive. That middleware primitive is architecturally adjacent to the AEAP Composition Boundary, which makes this one of the cleanest adapter integrations in the Wave 1 set. AEAP sits in the middleware chain; the agent gets independently verifiable authorization for every consequential action without application code changes.

The framework also positions **workflows** around explicit execution paths — nodes with declared pre- and post-conditions. AEAP's second integration surface in this adapter is the workflow-node wrapper.

See the [AEAP specification](https://github.com/aiyoplane/aeap) §9 for the Composition Boundary primitive this adapter realizes.

## Minimal usage — middleware integration

```python
from agent_framework import Agent
from aiyoplane_mcp_authz import create_aiyo_mcp_authz, create_local_rdp
from aiyoplane_microsoft_agent_framework import (
    AiyoAgentMiddleware,
    BlockedByPolicy,
    EscalationRequired,
)

policy = {
    "rules": [
        {"action_type": "payment", "amount_max": 1_000, "effect": "allow"},
        {"action_type": "payment", "amount_max": 10_000, "effect": "escalate"},
        {"action_type": "payment", "effect": "block"},
    ]
}

authz = create_aiyo_mcp_authz(
    rdp=create_local_rdp(policy=policy),
    tool_config={
        "transfer_funds": {"aiyo_gated": True, "action": {"type": "payment"}},
    },
)

aiyo_mw = AiyoAgentMiddleware(
    authz=authz,
    intent_builders={
        "transfer_funds": lambda payload: {
            "type": "payment",
            "amount": payload["amount"],
            "target": payload["to_account"],
        },
    },
)

agent = Agent(
    name="banker",
    instructions="Help the user manage their accounts.",
    middleware=[aiyo_mw, ...],
)
```

The middleware pattern: AEAP runs before every action matching an entry in `intent_builders`. Non-registered actions pass through unchanged (explicit opt-in).

## Minimal usage — workflow node wrapping

For workflow nodes defined as plain callables, use `wrap_action`:

```python
from aiyoplane_microsoft_agent_framework import wrap_action

async def deploy(target: str, artifact_hash: str) -> str:
    return actually_deploy(target, artifact_hash)

guarded_deploy = wrap_action(
    deploy,
    authz=authz,
    tool_name="deploy",
    intent_builder=lambda kwargs: {
        "type": "deploy",
        "target": kwargs["target"],
        "artifact": kwargs["artifact_hash"],
    },
)

# Register with your workflow the usual way.
```

## Composition Boundary — what the adapter actually does

For each gated action:

1. **Intent construction.** `intent_builder(action_payload)` produces an AEAP Intent payload.
2. **RDP evaluation.** Via `aiyoplane-mcp-authz`'s AiyoAuthz middleware.
3. **Verdict composition.**
   - **ALLOW** → action proceeds to the next middleware / inner function; receipt attached to context.
   - **ESCALATE** → `EscalationRequired` is raised.
   - **BLOCK** → `BlockedByPolicy` is raised; the action never executes.
4. **Fail-closed default** on every ambiguous condition.

## Local vs. hosted RDP

```python
from aiyoplane_mcp_authz import create_local_rdp, create_hosted_rdp

# Development:
authz = create_aiyo_mcp_authz(rdp=create_local_rdp(policy=policy), tool_config={...})

# Production:
authz = create_aiyo_mcp_authz(
    rdp=create_hosted_rdp(api_key="aiyo_live_..."),
    tool_config={...},
)
```

## API reference

### `AiyoAgentMiddleware(*, authz, intent_builders, attach_receipt_key="aeap_receipt")`

Middleware class. Register in the agent's middleware chain. Hook: `before_action(context, action)`.

### `aiyo_middleware(*, authz, intent_builders, attach_receipt_key="aeap_receipt")`

Convenience factory for `AiyoAgentMiddleware`.

### `wrap_action(fn, *, authz, tool_name, intent_builder, attach_receipt=False)`

Function-level wrapper for workflow nodes or direct function invocations outside the middleware chain.

### Exceptions

- `AiyoMSAgentFrameworkError` — base class
- `AdapterConfigError`, `BlockedByPolicy`, `EscalationRequired`

## License

Apache License 2.0.

## Links

- **AEAP specification:** https://github.com/aiyoplane/aeap
- **Underlying implementation:** [`aiyoplane-mcp-authz`](https://pypi.org/project/aiyoplane-mcp-authz/)
- **Node sibling:** `@aiyoplane/microsoft-agent-framework` on npm
- **Trust surface:** https://aiyoplane.com/trust
- **Issues:** https://github.com/aiyoplane/microsoft-agent-framework-python/issues

Microsoft, Microsoft Agent Framework, AutoGen, and Semantic Kernel are trademarks of Microsoft Corporation. This package is an independent AEAP Composition Boundary Adapter and is not affiliated with or endorsed by Microsoft Corporation.

**Verify First. Execute Second.**
