Skip to main content

AgentLens Python SDK — fleet governance for multi-framework agent stacks

Project description

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

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

agentlens_kk-0.1.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

agentlens_kk-0.1.2-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file agentlens_kk-0.1.2.tar.gz.

File metadata

  • Download URL: agentlens_kk-0.1.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for agentlens_kk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 815ff86edf42214152c72801d492da9eb1bafbb16c2d5d634c749682f157bfec
MD5 1600601d51b56ecfd7f51ec1ac2c04f7
BLAKE2b-256 92d98a4b95c077b2fe4b49184f375d79f4388d4e341c0ff908fa8440542e84b3

See more details on using hashes here.

File details

Details for the file agentlens_kk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: agentlens_kk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for agentlens_kk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9eda930f469a6e7a189550c607506c36523a5e06798067824200c7f3da567b
MD5 23f9ae0e0d034604c3f3e2a2580083fb
BLAKE2b-256 6c92bb23d7ade479e3e8ae2fb869a556c339e6820c8b17d57fff375e3ac37e8f

See more details on using hashes here.

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