Skip to main content

Drop-in monitoring for GenAI applications

Project description

stakeout-agent

Drop-in monitoring for LangGraph applications. Captures every graph run, node execution, and tool call into MongoDB with no changes to your graph code.

Why stakeout-agent?

When building LangGraph applications, understanding how your graphs execute is critical for debugging and optimization. stakeout-agent provides:

  • Zero code changes — just add a callback to your graph config
  • Complete visibility — captures node starts/ends, tool calls, and errors
  • MongoDB storage — leverage your existing infrastructure
  • Framework-agnostic core — easily extensible to other frameworks

Installation

pip install stakeout-agent

Requires Python 3.10+ and a running MongoDB instance.

Quick start

Sync (graph.invoke)

from stakeout_agent import LangGraphMonitorCallback

monitor = LangGraphMonitorCallback(graph_id="my_graph", thread_id="thread_123")
result = graph.invoke(inputs, config={"callbacks": [monitor]})

Async (graph.ainvoke / graph.astream)

from stakeout_agent import AsyncLangGraphMonitorCallback

monitor = AsyncLangGraphMonitorCallback(graph_id="my_graph", thread_id="thread_123")
result = await graph.ainvoke(inputs, config={"callbacks": [monitor]})

Configuration

Environment variable Default Description
MONGO_URI mongodb://localhost:27017 MongoDB connection string
MONGO_DB stakeout Database name

What gets recorded

runs collection

One document per graph invocation.

{
  "_id": "<run_id>",
  "graph_id": "my_graph",
  "thread_id": "thread_123",
  "status": "completed",
  "started_at": "2026-04-25T10:00:00Z",
  "ended_at": "2026-04-25T10:00:05Z",
  "error": null,
  "metadata": {}
}

status is one of running, completed, or failed.

events collection

One document per node start/end, tool call, or error within a run.

{
  "run_id": "<run_id>",
  "graph_id": "my_graph",
  "event_type": "node_end",
  "node_name": "agent",
  "timestamp": "2026-04-25T10:00:03Z",
  "latency_ms": 1240.5,
  "payload": {},
  "error": null
}
event_type When
node_start A graph node begins execution
node_end A graph node completes
tool_call A tool is invoked
tool_result A tool returns a result
error A node or tool raises an exception

Using MonitorDB directly

from stakeout_agent import MonitorDB

db = MonitorDB()

# fetch all runs for a graph
runs = list(db.runs.find({"graph_id": "my_graph"}).sort("started_at", -1))

# fetch events for a specific run
events = list(db.events.find({"run_id": "<run_id>"}).sort("timestamp", 1))

Package structure

stakeout_agent/
├── callback_handler/
│   ├── base.py        # _MonitorBase — framework-agnostic core logic
│   ├── langgraph.py   # LangGraphMonitorCallback, AsyncLangGraphMonitorCallback
│   └── __init__.py
└── db.py              # MonitorDB

Adding support for another framework means adding a single file under callback_handler/ that inherits from _MonitorBase and implements the target framework's callback protocol.

Possible Dashboard implementation

Utilizing the stored data, you could build a dashboard to visualize graph runs, node execution timelines, and tool call details. For example, a timeline view of node executions within a run could look like this:

Alt text

License

MIT

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

stakeout_agent-0.0.1a0.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file stakeout_agent-0.0.1a0.tar.gz.

File metadata

  • Download URL: stakeout_agent-0.0.1a0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for stakeout_agent-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 4cf2dcec6b55da7ae86235407112eb327440bd059c0e77b73e2836bd0e09f81a
MD5 c9a8a0b538d19902a7793277954bae88
BLAKE2b-256 730e41e57db9ed2228828a8a489763746e903a4d834d390afc65e711417376d0

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