> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agnost.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# PraisonAI

> Capture PraisonAI agent runs, LLM calls, and tool calls in Agnost AI

## Choose a setup method

| Method | Use it when |
| - | - |
| **Agnost AI skill** | You want your coding agent to inspect the app, make the change, and verify it. |
| **Agnost AI SDK** | You want explicit control over the interaction boundaries and fields. |
| **OpenTelemetry** | The framework already emits useful spans or you operate an OTel pipeline. |

Start with one method for a call path. Combining SDK tracking with framework
OpenTelemetry on the same call can create duplicate interactions.

## Recommended: Agnost AI skill

> [!NOTE]
>
> **Recommended.** Choose this path when you want your coding agent to inspect the
> project, select a supported transport, make the smallest instrumentation change,
> send a test event, and verify that it reached Agnost AI.

Install the skill once in your coding-agent environment:

```bash theme={null}
npx skills add AgnostAI/skills --skill agnost-ai
```

Run the framework-specific prompt below from the application root. Review the
resulting diff before deploying it.

```text theme={null}
Use the agnost-ai skill to add Agnost AI analytics to this PraisonAI application.
Org ID: your-org-id
Instrument the real agent.start() path and verify one fresh interaction.
```

## Manual setup: Agnost AI SDK

Use this when you want one Agnost AI event per agent turn with the exact input and output you choose.

```bash theme={null}
pip install praisonaiagents agnost
```

```python theme={null}
import agnost
from praisonaiagents import Agent

agent = Agent(
    name="support",
    instructions="Answer in one short sentence.",
    model="anthropic/claude-haiku-4-5",
)

agnost.init("your-org-id")
interaction = agnost.begin(
    user_id="u-42",
    agent_name="praisonai-support",
    input=prompt,
    conversation_id="sess-123",  # groups turns into one conversation
)
if interaction is None:
    raise RuntimeError("Agnost is not initialized. Call agnost.init() first.")
try:
    response = agent.start(prompt)
    interaction.end(output=str(response))
except Exception as exc:
    interaction.end(output=str(exc), success=False)
    raise
```

Call `agnost.shutdown()` once when the application exits, not after each request.
Shutting down per request disables telemetry for later agent runs in the same process.

## Manual setup: OpenTelemetry

PraisonAI sends provider-prefixed models such as `anthropic/claude-haiku-4-5` through LiteLLM.
The OpenInference LiteLLM instrumentor turns each model call into an OpenInference `LLM` span,
which Agnost AI accepts. PraisonAI does not emit agent or tool spans of its own, so the setup
below adds them with OpenInference's `@tracer.agent` and `@tracer.tool` decorators.

### Install

```bash theme={null}
pip install "praisonaiagents[llm]" openinference-instrumentation-litellm \
            opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
```

### Setup

```python theme={null}
import os
from openinference.instrumentation import TracerProvider, using_attributes
from openinference.instrumentation.litellm import LiteLLMInstrumentor
from opentelemetry import trace
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://otel.agnost.ai"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "X-Agnost-Org-ID=<your-org-id>"

provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
LiteLLMInstrumentor().instrument(tracer_provider=provider)
tracer = provider.get_tracer(__name__)

from praisonaiagents import Agent

@tracer.tool
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"It is sunny and 22 C in {city}."

agent = Agent(
    name="weather-agent",
    instructions="Answer in one short sentence. Use the get_weather tool for weather questions.",
    model="anthropic/claude-haiku-4-5",
    tools=[get_weather],
)

@tracer.agent(name="weather-agent")
def run_agent(prompt: str) -> str:
    return agent.start(prompt)

with using_attributes(session_id="sess-123", user_id="u-42"):
    result = run_agent("What is the weather in Paris?")

provider.force_flush()
```

`TracerProvider` here comes from `openinference.instrumentation`. It is the standard OpenTelemetry
SDK provider plus the `agent` and `tool` decorators. `using_attributes` puts `session.id` and
`user.id` on every span inside the block, so Agnost AI groups the run into one conversation and
attributes it to the user.

One `agent.start()` call with one tool call produces four events in Agnost AI:

* an `agent` event named `weather-agent` with the prompt as input and the final answer as output
* one `llm` event per model call, with the user message, the reply, the model name, and token counts
* a `tool` event named `get_weather` with the tool arguments and result

`@tracer.tool` keeps the function name, signature, and docstring, so PraisonAI still builds the
same tool schema from it.

> [!NOTE]
>
> PraisonAI calls the OpenAI SDK directly, not LiteLLM, when `model` is a bare OpenAI name such as
> `gpt-4o-mini`. For that case also install `openinference-instrumentation-openai` and call
> `OpenAIInstrumentor().instrument(tracer_provider=provider)` next to the LiteLLM instrumentor.

### Verify

Run one `run_agent(...)` call, then open **Conversations** in Agnost AI and find `sess-123`.
Confirm the conversation shows user `u-42`, an `agent` event, `llm` events with input and output
text, and a `tool` event for each tool the agent called.

### Troubleshooting

* No events: confirm `OTEL_EXPORTER_OTLP_HEADERS` contains `X-Agnost-Org-ID=<your-org-id>` and that `provider.force_flush()` runs before a short script exits.
* No `llm` events: call `LiteLLMInstrumentor().instrument(...)` before the first agent run, and use a provider-prefixed model such as `anthropic/...`, or add the OpenAI instrumentor for bare OpenAI model names.
* Every run is a separate conversation: wrap the call in `using_attributes(session_id=..., user_id=...)` and reuse the same `session_id` for later turns.
* No `tool` events: decorate the tool functions with `@tracer.tool` before passing them to `Agent(tools=[...])`.
* Use one method per call path. Combining the Agnost AI SDK and OpenTelemetry on the same run creates duplicate events.

### References

* [PraisonAI observability overview](https://docs.praison.ai/docs/observability/overview)
* [PraisonAI tools](https://docs.praison.ai/docs/tools/tools)
* [OpenInference LiteLLM instrumentation](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-litellm)
* [OpenInference tracing helpers (`@tracer.agent`, `@tracer.tool`)](https://arize.com/docs/phoenix/tracing/how-to-tracing/setup-tracing/instrument)

## Next steps

* [Conversations](https://docs.agnost.ai/using-conversations.md): review the complete PraisonAI run.
* [Events](https://docs.agnost.ai/using-events.md): inspect agent, LLM, and tool events.
* [Patterns](https://docs.agnost.ai/using-patterns.md): organize production conversations by what users wanted.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.