Integrations / Semantic Kernel
To trace Semantic Kernel with Uncoil in Python, wrap the invocation with trace_agent and open a step around the kernel function or agent call. Plugins you mark show up as steps in order.
Your code
Semantic Kernel
Uncoil
One run.
Setup
The Python flavor of Semantic Kernel and the Uncoil SDK.
pip install uncoil-sdk semantic-kernelCreate a project in Uncoil, copy its API key and put it in the environment where your code runs. The SDK reads it from there, so nothing is hard-coded.
export UNCOIL_API_KEY="uncoil_sk_live_..."Semantic Kernel is async. trace_agent and span both work in async functions.
import uncoil
@uncoil.trace_agent(name="sk-assistant")
async def ask(question: str) -> str:
with uncoil.span("kernel-invoke", type="agent", input=question) as step:
result = await kernel.invoke(plugin_name="chat", function_name="answer", question=question)
step.set_output(str(result))
return str(result)A kernel function decorator is the best place for a step, because every call through it is then recorded wherever it comes from.
from semantic_kernel.functions import kernel_function
class OrdersPlugin:
@kernel_function(description="Look up an order by id")
async def lookup(self, order_id: str) -> str:
with uncoil.span("orders.lookup", type="tool", input=order_id) as step:
status = await orders_api.status(order_id)
step.set_output(status)
return statusRun your code one time, then open the Tracing page of your project. Your kernel call shows up as a run with its steps in order, plus the tokens, time and any error for each call.
Good to know
The Uncoil SDKs are available for Python and TypeScript. For Semantic Kernel in .NET or Java, you can send traces to the Uncoil API directly.
Good to know
Semantic Kernel calls models through its own connectors, so those requests are not wrapped automatically. Mark the function that makes them and you get its timing and output.
Full details in the documentation. All integrations are listed on the integrations page.
