Skip to main content

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

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()],
)

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

agentic_layer_sdk_msaf-0.17.1.tar.gz (87.3 kB view details)

Uploaded Source

Built Distribution

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

agentic_layer_sdk_msaf-0.17.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file agentic_layer_sdk_msaf-0.17.1.tar.gz.

File metadata

  • Download URL: agentic_layer_sdk_msaf-0.17.1.tar.gz
  • Upload date:
  • Size: 87.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agentic_layer_sdk_msaf-0.17.1.tar.gz
Algorithm Hash digest
SHA256 6f37ec1a5ec9affdae01622d61d30d551c60847202eefcc68559505456c2df3e
MD5 9e2a69c874803e047f8b69daee3a6f9d
BLAKE2b-256 188b431e37dea56eb4a007b6fcce03920724ba09d738fecb8f4310b6abadacc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_layer_sdk_msaf-0.17.1.tar.gz:

Publisher: publish.yml on agentic-layer/sdk-python

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

File details

Details for the file agentic_layer_sdk_msaf-0.17.1-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_layer_sdk_msaf-0.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3267b078dd7b176c004c9114992208e379d86c84340e1d6bce3fc8076d494b0
MD5 76e9f7369c104b9051ca7cc037d07ce9
BLAKE2b-256 dc05beac9f0502870a1e80b14355dcc53263bc81bae7eb8f097d99f1539ed560

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_layer_sdk_msaf-0.17.1-py3-none-any.whl:

Publisher: publish.yml on agentic-layer/sdk-python

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