AgentLens Python SDK
Fleet governance for multi-framework agent stacks.
pip install agentlens-sdk # core
pip install "agentlens-sdk[langchain]" # + LangChain
pip install "agentlens-sdk[crewai]" # + CrewAI
pip install "agentlens-sdk[autogen]" # + AutoGen
pip install "agentlens-sdk[all]" # everything
API: https://agentlens-api-production.up.railway.app
Quick start (any framework)
import agentlens
agentlens.init("al_live_xxx") # or set AGENTLENS_API_KEY env var
with agentlens.trace("my-agent") as run:
result = my_agent.run(input)
run.tool_call("search", input="query", output="results")
run.complete(result)
Decorator style
import agentlens
agentlens.init("al_live_xxx")
@agentlens.monitor
def my_agent(input):
return result
# or with options:
@agentlens.monitor(agent_id="my-agent")
async def my_async_agent(input):
return result
Record tools without a trace context
agentlens.record_tool("send_email", input="to: user@example.com", output="sent")
LangChain (auto-instrumented)
import agentlens
agentlens.init("al_live_xxx")
# LangChain detected and instrumented automatically
agent.invoke({"input": "..."})
Or manually:
from agentlens import AgentTracer
from agentlens.langchain import AgentLensCallbackHandler
tracer = AgentTracer(api_key="...", api_url="https://agentlens-api-production.up.railway.app", agent_id="my-agent")
handler = AgentLensCallbackHandler(tracer)
result = executor.invoke({"input": "..."}, config={"callbacks": [handler]})
tracer.shutdown()
CrewAI
from agentlens.crewai import AgentLensCrewListener
listener = AgentLensCrewListener(api_key="...", api_url="https://agentlens-api-production.up.railway.app", agent_id="my-crew")
crew = Crew(agents=[...], tasks=[...], event_listeners=[listener])
crew.kickoff()
AutoGen
import agentlens
agentlens.init("al_live_xxx")
agentlens.wrap_agent(assistant) # registers hooks on the agent instance
chat_result = assistant.initiate_chat(user_proxy, message="...")
Or manually:
from agentlens.autogen import AgentLensAutoGenHook, wrap_agent
hook = AgentLensAutoGenHook(api_key="...", api_url="https://agentlens-api-production.up.railway.app", agent_id="my-agent")
wrap_agent(assistant, hook)
chat_result = assistant.initiate_chat(user_proxy, message="...")
hook.tracer.shutdown()
Event types
All event types match packages/core/src/schema.ts:
| Category | Types |
|---|---|
| Agent | agent.started agent.completed agent.failed agent.paused |
| Step | step.started step.completed step.failed step.retried |
| Tool | tool.called tool.returned tool.errored |
| LLM | llm.request llm.response llm.hallucination_suspected |
| Memory | memory.read memory.write |
| HITL | hitl.checkpoint_created hitl.approved hitl.rejected hitl.timeout |
| Cost | cost.token_usage |
Release files for agentlens-kk 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentlens_kk-0.1.2.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentlens_kk-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.1 kB
Release files / agentlens_kk-0.1.2.tar.gz
| Download URL | agentlens_kk-0.1.2.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
815ff86edf42214152c72801d492da9eb1bafbb16c2d5d634c749682f157bfec
|
|
BLAKE2b-256 checksum How to use checksums |
92d98a4b95c077b2fe4b49184f375d79f4388d4e341c0ff908fa8440542e84b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / agentlens_kk-0.1.2-py3-none-any.whl
| Download URL | agentlens_kk-0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d9eda930f469a6e7a189550c607506c36523a5e06798067824200c7f3da567b
|
|
BLAKE2b-256 checksum How to use checksums |
6c92bb23d7ade479e3e8ae2fb869a556c339e6820c8b17d57fff375e3ac37e8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|