No project description provided
Project description
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
from agent_framework import Agent
from agenticlayer.msaf import create_metrics_middleware, create_openai_client
from agenticlayer.msaf.agent_to_a2a import to_a2a
agent = Agent(
client=create_openai_client(),
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
OpenAI-compatible gateway (LiteLLM proxy)
Set the following environment variables to point the agent at an OpenAI-compatible gateway such as LiteLLM proxy:
| Variable | Description |
|---|---|
LITELLM_PROXY_API_BASE |
Base URL of the gateway, e.g. http://litellm-proxy:4000 |
LITELLM_PROXY_API_KEY |
API key for the gateway |
OPENAI_CHAT_MODEL_ID |
Model name to use, e.g. gpt-4o |
create_openai_client() reads these variables automatically and passes them to
OpenAIChatClient as base_url and api_key.
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:
from agent_framework import Agent
from agenticlayer.msaf import create_metrics_middleware, create_openai_client
agent = Agent(
client=create_openai_client(),
instructions="You are a helpful assistant.",
middleware=create_metrics_middleware(),
)
If you already have other middleware, combine them:
agent = Agent(
client=create_openai_client(),
instructions="You are a helpful assistant.",
middleware=[MyCustomMiddleware(), *create_metrics_middleware()],
)
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 agentic_layer_sdk_msaf-0.13.5.tar.gz.
File metadata
- Download URL: agentic_layer_sdk_msaf-0.13.5.tar.gz
- Upload date:
- Size: 81.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ab3c75a09b442e4988f0eaccabf5adb76c93fdd0af0b782c00300820fb41c31
|
|
| MD5 |
fc0191b66cb448b6740f04f421b9a591
|
|
| BLAKE2b-256 |
5c6a7a3317c065187920dfeb4d7e339b9836781b348bedf1d53b653fcc50be45
|
Provenance
The following attestation bundles were made for agentic_layer_sdk_msaf-0.13.5.tar.gz:
Publisher:
publish.yml on agentic-layer/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentic_layer_sdk_msaf-0.13.5.tar.gz -
Subject digest:
0ab3c75a09b442e4988f0eaccabf5adb76c93fdd0af0b782c00300820fb41c31 - Sigstore transparency entry: 1049130042
- Sigstore integration time:
-
Permalink:
agentic-layer/sdk-python@b53e88438f787a4f7ac43ac4b8d9ba6587360bd0 -
Branch / Tag:
refs/tags/v0.13.5 - Owner: https://github.com/agentic-layer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b53e88438f787a4f7ac43ac4b8d9ba6587360bd0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file agentic_layer_sdk_msaf-0.13.5-py3-none-any.whl.
File metadata
- Download URL: agentic_layer_sdk_msaf-0.13.5-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cde94bff338a4b242a50ca34feb1aad4b268631d15941100d8e00fd2cc591478
|
|
| MD5 |
bad4f6ef5664adf1a8db640234f6bfc2
|
|
| BLAKE2b-256 |
d21de3fa34e0562bd1cf5e0b9b6b141264701fcc9da05d34d079511769a5b30c
|
Provenance
The following attestation bundles were made for agentic_layer_sdk_msaf-0.13.5-py3-none-any.whl:
Publisher:
publish.yml on agentic-layer/sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentic_layer_sdk_msaf-0.13.5-py3-none-any.whl -
Subject digest:
cde94bff338a4b242a50ca34feb1aad4b268631d15941100d8e00fd2cc591478 - Sigstore transparency entry: 1049130053
- Sigstore integration time:
-
Permalink:
agentic-layer/sdk-python@b53e88438f787a4f7ac43ac4b8d9ba6587360bd0 -
Branch / Tag:
refs/tags/v0.13.5 - Owner: https://github.com/agentic-layer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b53e88438f787a4f7ac43ac4b8d9ba6587360bd0 -
Trigger Event:
push
-
Statement type: