Skip to main content

komodor-agentops

Python SDK for AgentOps observability, including the worker runtime, with optional extras for framework integrations (LangChain, Claude Agent SDK, ADK, Agno).

Install

pip install komodor-agentops

# With framework adapters
pip install komodor-agentops[langchain]
pip install komodor-agentops[claude-code]
pip install komodor-agentops[adk]
pip install komodor-agentops[agno]
pip install komodor-agentops[all]           # Everything

Quick Start

@observe() decorator

Wrap functions to emit span events automatically:

from komodor_agentops import observe

@observe(name="summarize", as_type="llm")
async def summarize(text: str) -> str:
    ...

AgentOps client (lightweight event buffer)

from komodor_agentops import AgentOps

client = AgentOps(agent_id="my-agent", endpoint="http://localhost:8000")
await client.log("Processing started", run_id="run_1")
await client.flush()

AgentOpsWorker — the whole of a worker's main()

A worker takes runs and returns results. It serves no HTTP and needs no inbound network access: it connects out to the control plane, is told when work is available, and claims it.

from pathlib import Path

from komodor_agentops import AgentOpsWorker, AgentSpec, Run

spec = AgentSpec.from_dir(
    Path(__file__).parent,
    agent_card={"skills": [{"id": "search", "name": "search"}]},
)

async def on_run(run: Run) -> dict:
    return {"answer": f"handled {run.input.get('prompt', '')}"}

def main() -> None:
    AgentOpsWorker(agent=spec, on_run=on_run).run()

run.input is the payload the run was created with; the dict you return becomes the run's output. Raise to fail the run — that is on_run's only failure channel, and the error is recorded on the run.

No host or port. Nothing dials your worker, so there is nothing to bind. A deployment needs egress to the control plane and no Service, Ingress or open port; the customer namespace chart denies inbound traffic by default.

A worker built against komodor-agentops 0.1.x may instead be using run_worker(agent, handler) with a handler taking an A2AMessage and returning an A2ATask, served on a port. That runtime is gone: it served an A2A app nothing dials any more. Move the handler to on_run= — it receives a Run and returns a mapping — and construct AgentOpsWorker from the package root as above. Run.input is the whole payload the message's parts used to carry, and the answer's human-readable half is the reserved text key rather than an artifact.

The standard AgentOps agent layout is:

my_agent/
  agent-spec.yaml
  agent.md
  worker.py
  skills/
    triage.md
    rca/SKILL.md

AgentSpec.from_dir(Path(__file__).parent, ...) requires agent-spec.yaml, then loads agent.md and skills/ automatically. The worker registers loaded skills during heartbeat, and SDK-owned LLM adapters can prepend the agent context at invocation time.

schema_version: 1
agent_id: my-agent
name: My Agent
description: Does useful work.
owner: AgentOps
repo: https://github.com/komodorio/agentops
source_path: packages/workers/my_agent
labels:
  category: example

agent-spec.yaml can also declare triggers — synced to the control plane on heartbeat and shown on the Fleet → Triggers surface. Supported types are schedule (cron), webhook (inbound HTTP endpoint), and slack_channel (subscribe the agent to Slack channels by NAME, not ID — the control plane materialises a routing rule per channel on heartbeat and dispatches matching messages; the agent is invoked when @mentioned in one of those channels):

triggers:
  - id: incidents-sub
    type: slack_channel
    name: Incident channels
    channels:
      - "#incidents" # normalized to "incidents" — lowercase, no "#"
      - alerts

To make a worker available in the AgentOps Chat UI, advertise chat capability on its agent card:

spec = AgentSpec(
    agent_id="my-chat-agent",
    agent_card={
        "name": "My Chat Agent",
        "capabilities": {"chat": True, "ask": True, "streaming": True},
    },
)

A chat run arrives like any other run: run.input carries messages (the conversation history), model, and prompt (the latest user text). There are no A2A message parts to unpack — the control plane creates a run and your worker claims it, so a chat handler reads the same run.input dict as every other handler.

To stream the answer as it is produced rather than returning it whole, emit it through the ambient client; the control plane relays each new piece of the run's answer text to the browser as it appears.

Event Hooks — rewriting or withholding telemetry before it leaves

Subclass AgentOpsHook and pass instances to the worker. Each callback may return the event unchanged, return a modified one, or return None to drop it — so a tool payload carrying customer data can be rewritten or withheld, and nothing downstream sees the original. before_flush does the same for a whole batch; after_flush reports what was sent.

Every event this worker records crosses one place on its way out, so a hook sees all of it — including the spans the adapters record ambiently, which never pass through your code.

from komodor_agentops import AgentOpsWorker
from komodor_agentops.core.events import AgentOpsEvent
from komodor_agentops.core.hooks import AgentOpsHook


class RedactToolInput(AgentOpsHook):
    async def before_tool(self, event):
        return AgentOpsEvent(**{**vars(event), "payload": {"input": "[redacted]"}})


AgentOpsWorker(agent=spec, on_run=on_run, hooks=[RedactToolInput()]).run()

A hook that raises is logged and its event passes through unchanged, so a buggy rule cannot cost a run its whole transcript. Pass strict_hooks=True to invert that: for a hook whose job is to withhold data, passing the event through on failure ships exactly what it existed to remove, so the failure should propagate instead.

Framework Adapters

LangChain

Spans for each chain, model and tool call, nested under the run's own span. It needs no client: the events go to the ambient buffer the worker's flush cycle already drains, so it only produces spans inside a run scope.

from komodor_agentops.adapters.langchain import ContextCallbackHandler

chain.invoke(input, config={"callbacks": [ContextCallbackHandler()]})

Claude Code

SDK hooks for claude-agent-sdk:

from komodor_agentops.adapters.claude_code.sdk_hooks import agent_ops_hooks_for_run

hooks = agent_ops_hooks_for_run("run_1")

Architecture

komodor-agentops
  agentops-rpc, agentops-otel (wire types + OTel bootstrap)
  httpx, pydantic, pydantic-settings, croniter, pyyaml, python-frontmatter
    |
    +-- [langchain]   -> langchain-core
    +-- [claude-code] -> claude-agent-sdk
    +-- [adk]         -> google-adk
    +-- [agno]        -> agno, anthropic
    +-- [server]      -> no-op alias (kept so existing [server] refs resolve; the SDK
                         serves no HTTP, so there is nothing for it to pull in)

Package Structure

src/komodor_agentops/
  __init__.py       # Public API — the root is the API; submodule paths are internal
  worker_runtime.py # AgentOpsWorker: connect, register, claim, run, report
  worker_client.py  # The worker protocol, and the run scope
  messaging.py      # The transport's composition root (downlink + uplink)
  client.py         # Event buffer + flush
  py.typed          # PEP 561 marker
  transport/        # The byte-level connection (SSE, reconnect)
  bus/              # Frames: the envelope, the router, the uplink
  machinery/        # Delivery: batching, retry, sequencing
  core/             # Context, events, secrets, types, @observe
  worker/           # Run contract, liveness, local runner, log forwarding
  adapters/         # Claude Code, ADK, Agno, LangChain, nanobot

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

komodor_agentops-0.3.4.tar.gz (379.1 kB view details)

Uploaded Source

Built Distribution

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

komodor_agentops-0.3.4-py3-none-any.whl (230.0 kB view details)

Uploaded Python 3

File details

Details for the file komodor_agentops-0.3.4.tar.gz.

File metadata

  • Download URL: komodor_agentops-0.3.4.tar.gz
  • Upload date:
  • Size: 379.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for komodor_agentops-0.3.4.tar.gz
Algorithm Hash digest
SHA256 742ffabfda5719dba63de8448b5db721686b310b4da0c82365a82e9decea9d4d
MD5 6ac47a9ed7ab0223d0c390532a320cb4
BLAKE2b-256 68f9e2bf18779a05e4451d733f2a9fdc4eaf7445940a68b64c3c8a53de465796

See more details on using hashes here.

File details

Details for the file komodor_agentops-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: komodor_agentops-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 230.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.13 {"installer":{"name":"uv","version":"0.11.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for komodor_agentops-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14f29b3d7d3a8e98887e7453ddb0a6fb00ba67c12cf5eedfcf4514d76c26657a
MD5 d7b521368cf1ffed7d4eca43bb2b7498
BLAKE2b-256 fa8d523d46d25836e45733d56c5711ccfad1e092fbb5205adf33e2289315f0e9

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 Sentry Error logging StatusPage Status page