# Audit evidence from Langfuse traces

Langfuse shows your team what an agent did. Add one span processor to the same tracing set-up and each tool call also becomes a signed `decision` and `outcome` record on your machine, which a witness co-signs once you send its hash and an auditor verifies offline.

Langfuse keeps receiving the same spans: the processor reads them inside your process and exports nothing. How it works, the verify output and sampling: [Audit log from OpenTelemetry traces](/docs/frameworks/opentelemetry).

## Python

Langfuse's Python SDK sets the OpenTelemetry tracer provider, and Pydantic AI writes its spans to it. Add the package to the project that has both.

```bash
pip install "signafaide[otel]"
```

```python
from langfuse import get_client
from opentelemetry import trace
from pydantic_ai import Agent
from signafaide.otel import SignafaideSpanProcessor

langfuse = get_client()  # Langfuse's own line
trace.get_tracer_provider().add_span_processor(
    SignafaideSpanProcessor(agent="support-bot")
)  # the one line

Agent.instrument_all()  # Langfuse's own line
agent = Agent(model)  # model: the model you already use

@agent.tool_plain
def refund(order: str, amount: float) -> str:
    """Refund an order."""
    return f"refunded {amount} on {order}"

agent.run_sync("Refund order A1, 5 pounds")
```

## TypeScript

Langfuse's set-up for the Vercel AI SDK is a list of span processors. Add the package, then one entry to the list.

```bash
npm install signafaide
```

```ts
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { LangfuseVercelAiSdkIntegration } from "@langfuse/vercel-ai-sdk";
import { NodeSDK } from "@opentelemetry/sdk-node";
import { generateText, registerTelemetry, stepCountIs, tool } from "ai";
import { SignafaideSpanProcessor } from "signafaide/otel";
import { z } from "zod";

const sdk = new NodeSDK({
  spanProcessors: [
    new LangfuseSpanProcessor(), // Langfuse's own line
    new SignafaideSpanProcessor({ agent: "support-bot" }), // the one line
  ],
});
sdk.start();
registerTelemetry(new LangfuseVercelAiSdkIntegration()); // Langfuse's own line

await generateText({
  model, // the model you already use
  prompt: "Refund order A1, 5 pounds",
  stopWhen: stepCountIs(3),
  tools: {
    refund: tool({
      description: "Refund an order.",
      inputSchema: z.object({ order: z.string(), amount: z.number() }),
      execute: async ({ order, amount }) => `refunded ${amount} on ${order}`,
    }),
  },
});
await sdk.shutdown(); // sends the buffered spans before the script exits
```

Both samples run with version 5 of Langfuse's Python SDK and Pydantic AI 2, and with version 6 of the `@langfuse` packages and AI SDK 7.

## Before the tool ran, or after

Before, in both samples. Pydantic AI and the Vercel AI SDK start each tool span with its attributes set, so the decision is signed and chained before the tool runs. `signafaide verify` says so:

```text
telemetry: _pending/nokey/support-bot: 1 tool is recorded from telemetry spans: refund (decision written before the tool ran)
```

With another instrumentation the answer can differ, and every record says which it was: [Before the tool ran, or after](/docs/frameworks/opentelemetry#before-the-tool-ran-or-after).

## What is recorded and what is not

- **Recorded.** Each tool call whose span follows the OpenTelemetry GenAI, OpenInference or OpenLLMetry convention: the tool name and arguments, then the result or the error.
- **Not recorded.** A span Langfuse writes in its own convention, such as a function marked `@observe(as_type="tool")`, is not a tool call to the processor. Wrap that function with the SDK, and its decision is written before it runs: [Quickstart](/docs/quickstart).
- **Sampling.** A span the sampler drops never reaches the processor, so its tool call has no record. With an always-on sampler none is dropped: [Sampling](/docs/frameworks/opentelemetry#sampling).
- **Protecting a tool needs the SDK.** The processor never stops a tool. To run a tool only once its record is confirmed, wrap it with the SDK.
- **Checks stay Calibrating.** With a checks file in place, the processor records the [tool-call checks](/docs/checks) of each tool call it reads, always Calibrating: it notes what they find and never blocks, and it never asks the witness for a ruling.
- **Evidence, not certification.** Records prove integrity and timing, not that a decision was right. The co-signature and the public timestamp come after `signafaide init`, which creates a free sandbox and sends only salted hashes.

Next: start free, with the SDK alone and no account. [Quickstart](/docs/quickstart)
