---
title: Fix and verify LangGraph agent behavior with Converra
description: Send LangGraph text conversations to Converra, diagnose the failing turn, simulate a fix, and verify the approved production change.
---

# LangGraph integration

Converra diagnoses failures in LangGraph agent conversations, generates bounded behavior fixes, and compares them against your current agent in simulation. You approve the change, then receive a production verdict: **verified, not fixed, or confounded**.

## Install

```bash
pip install converra langgraph langchain-openai
```

Set `CONVERRA_API_KEY`, `OPENAI_API_KEY`, and `OPENAI_MODEL` in your server environment. Use a Python version supported by LangGraph.

## Send the completed graph conversation

This example uses a single text-only node and no persistent checkpointer. Converra receives the graph's actual user and assistant messages, after execution completes.

```python
import os

from converra import Converra
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_openai import ChatOpenAI
from langgraph.graph import END, START, MessagesState, StateGraph

converra = Converra(api_key=os.environ['CONVERRA_API_KEY'])
model = ChatOpenAI(model=os.environ['OPENAI_MODEL'])


def respond(state: MessagesState):
    instructions = SystemMessage(
        content='Ask for an order number before discussing refund eligibility.'
    )
    return {'messages': [model.invoke([instructions, *state['messages']])]}


builder = StateGraph(MessagesState)
builder.add_node('respond', respond)
builder.add_edge(START, 'respond')
builder.add_edge('respond', END)
graph = builder.compile()

try:
    result = graph.invoke({'messages': [HumanMessage(content='Can I get a refund?')]})
    roles = {'human': 'user', 'ai': 'assistant'}
    messages = []
    for message in result['messages']:
        if message.type not in roles or not isinstance(message.content, str):
            raise ValueError('This example supports user and assistant text only')
        messages.append({'role': roles[message.type], 'content': message.content})
    run = converra.send(
        agent='Refund support',
        messages=messages,
        metadata={'source': 'langgraph'},
    )
    print(run.conversation_id)
finally:
    converra.shutdown()
```

For graphs with tools, handoffs, images, or multiple agents, preserve that evidence using [enriched messages and trace lineage](/sdk/python). The text adapter above deliberately rejects message shapes it cannot represent. If LangSmith already captures your graph, the [LangSmith connector](/guide/integrations/langsmith) is another ingestion path; avoid importing the same conversations twice.

For a graph with conversation history, append only new turns to the saved Converra conversation ID rather than sending the entire accumulated state on every invocation. Register the real instructions for each agent in Converra before optimizing.

## Fix the failing behavior

Use [Converra through your coding agent](/mcp/coding-agents) to inspect the failing turn, generate a bounded change, and compare it against the baseline in simulation. Apply the approved instructions to the relevant graph node. Code and routing changes remain your application's responsibility.

Continue sending production conversations after the change. Query `get_deployment_impact` and `get_verification_evidence` to inspect the result against the [verdict rules](/mcp/coding-agents#how-a-verdict-is-decided).

## References

Reviewed 2026-10-15: [LangGraph quickstart](https://docs.langchain.com/oss/python/langgraph/quickstart) for graph construction and invocation; [Converra Python SDK](/sdk/python) version 0.5.1 for explicit conversation delivery.
