# Audit evidence from Arize Phoenix traces

Phoenix shows your team what an agent did, from spans in the OpenInference convention. Add one span processor to the same tracer provider and each tool call also becomes a signed `decision` and `outcome` record on your machine.

Phoenix keeps receiving the same spans when its own processor is kept, as both samples do. The processor reads spans inside your process and exports nothing. How it works, the verify output and sampling: [Audit log from OpenTelemetry traces](/docs/frameworks/opentelemetry).

## Python

Add the package to the project that has `arize-phoenix-otel` and an OpenInference instrumentor, here the one for LangChain.

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

```python
from langchain.agents import create_agent
from langchain_core.tools import tool
from phoenix.otel import register
from signafaide.otel import SignafaideSpanProcessor

tracer_provider = register(  # Phoenix's own lines
    project_name="support-bot",
    auto_instrument=True,
)
tracer_provider.add_span_processor(  # the one line
    SignafaideSpanProcessor(agent="support-bot"),
    replace_default_processor=False,
)

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

agent = create_agent(model, tools=[refund])  # model: the model you already use
agent.invoke({"messages": [("user", "Refund order A1, 5 pounds")]})
```

Keep `replace_default_processor=False`. Phoenix's `add_span_processor` otherwise removes the processor that sends spans to Phoenix.

## TypeScript

In TypeScript, `spanProcessors` replaces Phoenix's default exporter, so name both: Phoenix's own processor and the added one.

```bash
npm install signafaide
```

```ts
import { LangChainInstrumentation } from "@arizeai/openinference-instrumentation-langchain";
import { getDefaultSpanProcessor, register } from "@arizeai/phoenix-otel";
import * as CallbackManagerModule from "@langchain/core/callbacks/manager";
import { createAgent, tool } from "langchain";
import { SignafaideSpanProcessor } from "signafaide/otel";
import { z } from "zod";

const provider = register({
  projectName: "support-bot", // Phoenix's own line
  spanProcessors: [
    getDefaultSpanProcessor({}), // Phoenix's own exporter, kept
    new SignafaideSpanProcessor({ agent: "support-bot" }), // the one line
  ],
});
new LangChainInstrumentation().manuallyInstrument(CallbackManagerModule); // Phoenix's own line

const refund = tool(
  async ({ order, amount }) => `refunded ${amount} on ${order}`,
  {
    name: "refund",
    description: "Refund an order.",
    schema: z.object({ order: z.string(), amount: z.number() }),
  },
);
const agent = createAgent({ model, tools: [refund] }); // model: the model you already use
await agent.invoke({
  messages: [{ role: "user", content: "Refund order A1, 5 pounds" }],
});
```

The samples run with `arize-phoenix-otel` 0.17 and `@arizeai/phoenix-otel` 3, the OpenInference LangChain instrumentations, and LangChain 1.

## Before the tool ran, or after

After, in both samples. The OpenInference LangChain instrumentation sets a span's attributes after the span has started, so the decision and the outcome are both written when the span ends, after the tool ran. `signafaide verify` says so:

```text
telemetry: _pending/nokey/support-bot: 1 tool is recorded from telemetry spans: refund (decision written after the tool ran)
telemetry: _pending/nokey/support-bot: telemetry sampling follows the caller: a tool call inside a trace that arrives marked as not sampled is not recorded
```

For a decision written before the tool runs, add the `langchain-signafaide` middleware or wrap the tools. The call is then recorded once, by the wrapper: [Audit log for LangChain agents](/docs/frameworks/langchain).

## What is recorded and what is not

- **Recorded.** Each tool call whose span says `openinference.span.kind` is `TOOL`: the tool name and arguments, then the result or the error.
- **Not recorded.** A tool call with no span, and a span the sampler 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, use the middleware or the wrapper to protect the tool.
- **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)
