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

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


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.14.0.tar.gz (83.9 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.14.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentic_layer_sdk_msaf-0.14.0.tar.gz
Algorithm Hash digest
SHA256 ac97f5c918352caee29ded35cf8988ce5452077992a377f2eb6abf36f8ad4645
MD5 15896eeb6be47a5ba0fd4699b5eca461
BLAKE2b-256 b5c6e0f5fef8ca1128253d6c641175dc4db759416e949950f0ef9286af052603

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_layer_sdk_msaf-0.14.0.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.14.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_layer_sdk_msaf-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1f577fec46c4e85ba7581159280bf4ea96b3a394ccc5b29e8db58ad8d6c6e98
MD5 21c1b748534cb44d51a745faa46bb979
BLAKE2b-256 94942a2d90a59b1ff28fefa0c4270508fedff8a88479845e9681d7815de55685

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_layer_sdk_msaf-0.14.0-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