Metadata-Version: 2.4
Name: glowtrace
Version: 0.3.4
Summary: See your multi-agent LLM app as a live graph: which agent is running, what it sent, and what came back.
Author: Eman Khadim
License-Expression: MIT
Project-URL: Homepage, https://github.com/emankhadim/glowtrace
Project-URL: Source, https://github.com/emankhadim/glowtrace
Project-URL: Issues, https://github.com/emankhadim/glowtrace/issues
Keywords: agents,llm,opentelemetry,observability,tracing,multi-agent,visualization,genai
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Framework :: AsyncIO
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp>=3.9
Requires-Dist: opentelemetry-proto>=1.20
Requires-Dist: websockets>=13
Provides-Extra: live
Requires-Dist: opentelemetry-sdk>=1.20; extra == "live"
Dynamic: license-file

<h1><img src="https://raw.githubusercontent.com/emankhadim/glowtrace/main/docs/logo.png" alt="glowtrace" width="360"></h1>

[![PyPI](https://img.shields.io/pypi/v/glowtrace)](https://pypi.org/project/glowtrace/)
[![Python](https://img.shields.io/pypi/pyversions/glowtrace)](https://pypi.org/project/glowtrace/)
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow)](https://github.com/emankhadim/glowtrace/blob/main/LICENSE)

**See your multi-agent app as a live graph: which agent is running, who it handed work to, and the exact prompt behind every step.**

![glowtrace demo](https://raw.githubusercontent.com/emankhadim/glowtrace/main/docs/demo.gif)

**[Try the demo in your browser](https://emankhadim.github.io/glowtrace/)**: it plays a built-in sample run, no install needed.

When three or four agents start passing work to each other, logs stop being enough. You can't tell which agent is stuck, which tool call failed, or what prompt actually went to the model. glowtrace shows you that while the run is happening.

- **Two commands, no code changes** for apps that already export OpenTelemetry traces
- **Live graph:** agents, LLM calls and tool calls appear as they run; failures turn red
- **Click any node** for the system prompt, messages, response, tool args and results, tokens and timing
- **Readable by default:** framework internals like `RunnableSequence` and prompt templates are folded away
- **Works across frameworks** that use OpenInference, OpenTelemetry GenAI or OpenLLMetry spans (tested end to end with LangGraph so far)

It's a debugging view for runs in progress. For stored history, evals and cost tracking, use it next to Phoenix or Langfuse rather than instead of them.

## Install and run

```bash
pip install glowtrace
glowtrace serve
```

The UI is at http://localhost:4318. Port 4318 is the default OTLP/HTTP port, so an app that already exports traces with default settings needs no changes. Otherwise:

```bash
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
export OTEL_BSP_SCHEDULE_DELAY=200   # optional, the default batch delay is 5 s
```

OTLP exporters only send a span when it ends, so by default a node appears once its step has finished. To see steps while they are still running, add this to your app (needs `pip install "glowtrace[live]"`):

```python
import glowtrace
glowtrace.instrument()
```

## What it reads

glowtrace maps spans that follow any of these conventions:

- [OpenInference](https://github.com/Arize-ai/openinference), used by the instrumentors for LangChain/LangGraph, LlamaIndex, CrewAI, the OpenAI Agents SDK and others
- [OpenTelemetry GenAI semantic conventions](https://opentelemetry.io/docs/specs/semconv/gen-ai/) (`gen_ai.*`)
- [OpenLLMetry](https://github.com/traceloop/openllmetry) (`traceloop.*`)

So far I have tested it end to end with LangGraph and with the unmodified [langgraph-supervisor](https://github.com/langchain-ai/langgraph-supervisor-py) quickstart. The other conventions are covered by unit tests, not by real runs. If a framework shows up wrong, an issue with the trace attached helps most.

Spans that carry no agent, LLM or tool meaning (HTTP calls, prompt templates, `RunnableSequence` and similar) are folded into their parent so the graph stays readable. `glowtrace serve --all-spans` turns this off.

### LangGraph setup

```python
from openinference.instrumentation.langchain import LangChainInstrumentor
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
import glowtrace

provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
glowtrace.instrument()   # optional
LangChainInstrumentor().instrument(tracer_provider=provider)
```

### Without OpenTelemetry

There is a small tracer for plain Python code:

```python
from glowtrace import Tracer

tr = Tracer()
tr.session("orch", "Orchestrator", input=question)
with tr.agent("a1", "researcher", parent="orch", system=SYSTEM, input=task) as a:
    with tr.tool("t1", "sql_query", parent="a1", args=sql) as t:
        t.result = run(sql)
    a.output, a.tokens = answer, usage
```

It sends JSON events over the `/ws` WebSocket, so any language can do the same:

| event | fields |
|---|---|
| `node` | `id, kind (session/step/agent/llm/tool), parent, title, status, model, system, input, args` |
| `update` | `id, status (waiting/running/done/error), note, output, result, tokens` |
| `message` | `from, to, content, label, tokens` |
| `remove` | `id` (its children move up to its parent) |

## Examples

The examples in `examples/` work with any OpenAI-compatible endpoint, including a local model through Ollama. Set `LLM_BASE_URL`, `LLM_API_KEY` and `LLM_MODEL` to point them somewhere else.

```bash
pip install "glowtrace[live]" openai langgraph langchain-openai langgraph-supervisor \
    openinference-instrumentation-langchain opentelemetry-exporter-otlp-proto-http
python examples/test_supervisor.py   # langgraph-supervisor quickstart
python examples/langgraph_team.py    # small LangGraph team
python examples/real_agents.py       # plain Python agents with the native tracer
python examples/fake_run.py          # scripted events, no LLM
```

## Limitations

- History is kept in memory only (the last 20,000 events) and is gone when the server stops. glowtrace is not a replacement for Phoenix or Langfuse if you need stored traces, evals or cost tracking.
- One process, no auth beyond an optional write token (`--token`). Without the token anyone who can reach the port can send data.
- Large runs with hundreds of nodes get crowded on screen.

## How it works

```
your app --OTLP/HTTP--> glowtrace serve --WebSocket--> browser
```

The server accepts protobuf or JSON OTLP, turns spans into graph events, and keeps a history so a tab opened mid-run can catch up. Exporters often send child spans before their parents, so an unknown parent gets a placeholder node that is filled in when its span arrives.

The UI is TypeScript without a framework. It builds into one HTML file that ships inside the Python package, so `pip install` does not need Node.

## Development

```bash
pip install -e ".[live]" pytest && pytest
cd web && npm install && npm test && npm run build
```

`glowtrace/` holds the server, the span mapper and the tracer. `web/src/` holds the UI. The built `glowtrace/static/index.html` is committed and CI checks that it matches the source.

MIT License
