
Instrument Your Agent in 5 Minutes
Getting full behavioral visibility into your AI agent does not require a rewrite. Vyrt is designed to sit alongside your existing agent code and capture execution data without changing how your agent works.
This walkthrough shows you exactly how to add Vyrt instrumentation to a LangChain agent, but the same principles apply to AutoGen, CrewAI, and custom-built agents.
What You Will Have at the End
After following this guide, every run of your agent will produce a structured behavioral record — including inputs, outputs, all tool calls with their parameters and return values, decision steps, and any failure signals. All of it queryable from the Vyrt dashboard.
Step 1: Install the SDK
npm install @vyrt/sdk
# or
pip install vyrt
Step 2: Initialize the Client
from vyrt import Vyrt
vyrt = Vyrt(api_key="your-api-key")
Set your API key as an environment variable in production:
VYRT_API_KEY=your-api-key
import os
from vyrt import Vyrt
vyrt = Vyrt(api_key=os.environ["VYRT_API_KEY"])
Step 3: Wrap Your Agent
For a LangChain agent, wrap the executor:
from langchain.agents import AgentExecutor
from vyrt.integrations.langchain import VyrtTracer
# Your existing agent setup
agent_executor = AgentExecutor(agent=agent, tools=tools)
# Add Vyrt instrumentation
tracer = VyrtTracer(client=vyrt)
result = agent_executor.invoke(
{"input": user_message},
config={"callbacks": [tracer]}
)
That's it. Every run now produces a full behavioral trace.
Step 4: Add Run Metadata (Optional but Recommended)
Tag your runs with metadata to make them easier to filter and search in the dashboard:
tracer = VyrtTracer(
client=vyrt,
metadata={
"user_id": current_user.id,
"session_id": session.id,
"agent_version": "v2.1.0",
"environment": "production"
}
)
This lets you filter by user, session, version, or environment when investigating failures.
Step 5: Verify in the Dashboard
Open your Vyrt dashboard. You should see your first run appear within a few seconds of execution. Click into it to see:
- The full input context
- Each step the agent took, in sequence
- Tool calls with parameters and return values
- Timing breakdown per step
- Any failure signals detected
Using Custom Agents
If you are not using a framework, you can instrument at the execution level directly:
with vyrt.trace(name="my-agent-run") as run:
run.log_input(user_message)
# Step 1
with run.step("plan") as step:
plan = generate_plan(user_message)
step.log_output(plan)
# Step 2
with run.step("tool-call") as step:
step.log_tool_call(tool_name="search", params={"query": plan.query})
result = search_tool(plan.query)
step.log_tool_result(result)
# Final output
response = generate_response(result)
run.log_output(response)
This gives you full control over what gets captured and at what granularity.
What Happens to Performance?
Vyrt captures behavioral data asynchronously. The instrumentation does not sit in the critical path of your agent's execution — data is batched and sent in the background after each step completes. In practice, the overhead is under 2ms per step in most configurations.
What to Look at First
Once you have a few runs captured, start here:
- Step count distribution — How many steps are your runs taking? Outliers often indicate loops or inefficiencies.
- Tool call failure rate — Which tools are returning errors most often?
- Run duration by input type — Are certain kinds of inputs consistently slower?
- Failed runs — Filter to runs Vyrt flagged as failures and open the execution trace for each.
Five minutes of instrumentation setup will save you hours of debugging later. Start with one agent, see what surfaces, and go from there.
Full visibility into every AI decision in production.