agentic-layer-sdk-msaf
Microsoft Agent Framework adapter for the Agentic Layer SDK.
This package provides utilities to convert a Microsoft Agent Framework agent into an instrumented A2A Starlette web application.
Usage
import os
from agent_framework import Agent
from agent_framework_openai import OpenAIChatCompletionClient
from agenticlayer.msaf import create_metrics_middleware
from agenticlayer.msaf.agent_to_a2a import to_a2a
agent = Agent(
client=OpenAIChatCompletionClient(
model=os.environ.get("AGENT_MODEL", "gemini-2.5-flash"),
base_url=os.environ.get("LITELLM_PROXY_API_BASE"),
api_key=os.environ.get("LITELLM_PROXY_API_KEY"),
),
name="MyAgent",
instructions="You are a helpful assistant.",
middleware=create_metrics_middleware(),
)
app = to_a2a(agent, name="MyAgent", rpc_url="http://localhost:8000/")
# Then run with: uvicorn module:app
Configuration
Observability
OpenTelemetry setup
Call setup_otel() before creating agents to configure OTLP exporters and enable instrumentation:
from agenticlayer.msaf.otel import setup_otel
setup_otel()
This reads standard OTEL_EXPORTER_OTLP_ENDPOINT / OTEL_EXPORTER_OTLP_PROTOCOL environment
variables, sets up trace/log/metric providers, and enables the built-in Agent Framework telemetry
layers.
Metrics
The SDK emits the following OpenTelemetry metrics:
Built-in (provided by Agent Framework telemetry layers, enabled by setup_otel()):
| Metric | Type | Description |
|---|---|---|
gen_ai.client.token.usage |
Histogram | Input and output token counts per LLM call |
gen_ai.client.operation.duration |
Histogram | Duration of LLM / agent operations |
Custom (provided by create_metrics_middleware(), must be added to the agent):
| Metric | Type | Description |
|---|---|---|
agent.invocations |
Counter | Number of agent invocations |
agent.llm.calls |
Counter | Number of LLM calls |
agent.tool.calls |
Counter | Number of tool calls |
agent.errors |
Counter | Number of errors (with error_source attribute) |
Add the metrics middleware to your agent:
import os
from agent_framework import Agent
from agent_framework_openai import OpenAIChatCompletionClient
from agenticlayer.msaf import create_metrics_middleware
agent = Agent(
client=OpenAIChatCompletionClient(
model=os.environ.get("AGENT_MODEL", "gemini-2.5-flash"),
base_url=os.environ.get("LITELLM_PROXY_API_BASE"),
api_key=os.environ.get("LITELLM_PROXY_API_KEY"),
),
instructions="You are a helpful assistant.",
middleware=create_metrics_middleware(),
)
If you already have other middleware, combine them:
import os
from agent_framework import Agent
from agent_framework_openai import OpenAIChatCompletionClient
agent = Agent(
client=OpenAIChatCompletionClient(
model=os.environ.get("AGENT_MODEL", "gemini-2.5-flash"),
base_url=os.environ.get("LITELLM_PROXY_API_BASE"),
api_key=os.environ.get("LITELLM_PROXY_API_KEY"),
),
instructions="You are a helpful assistant.",
middleware=[MyCustomMiddleware(), *create_metrics_middleware()],
)
Metadata
Release files for agentic-layer-sdk-msaf 0.18.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentic_layer_sdk_msaf-0.18.1.tar.gz | 91.0 kB | With provenance | Details for agentic_layer_sdk_msaf-0.18.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentic_layer_sdk_msaf-0.18.1-py3-none-any.whl | Python 3 | none | any | Details for agentic_layer_sdk_msaf-0.18.1-py3-none-any.whl |
Total release size: 102.8 kB
Release files / agentic_layer_sdk_msaf-0.18.1.tar.gz
| Download URL | agentic_layer_sdk_msaf-0.18.1.tar.gz |
|---|---|
| Size | 91.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eff9739161fb95a2ed03a21eb829468a8943e41a4a1753f6f019bc37cf7c2076
|
|
BLAKE2b-256 checksum How to use checksums |
11f8bcc3158afc905fb1a3f082623baba2aa76aa5896afa0ee49f840da80ee05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logRelease files / agentic_layer_sdk_msaf-0.18.1-py3-none-any.whl
| Download URL | agentic_layer_sdk_msaf-0.18.1-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
478c99e93bd042fe65f994cbf1ba5bce9461a503b4e596b7cce88a539b164412
|
|
BLAKE2b-256 checksum How to use checksums |
62ca03c9213b2c312daa5ddb28f3907b9f51757bba4c74b173b4f154c363a2d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logSecurity for agentic-layer-sdk-msaf 0.18.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agentic_layer_sdk_msaf-0.18.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 27, 2026.
Transparency logA 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.