This example demonstrates X-Ray analyzing a real LangChain refinement workflow built with runnable composition.
LangChain primitives used:
ChatPromptTemplateChatOpenAIStrOutputParser- pipe composition (
prompt | llm | parser)
Original inspiration:
Model:
- default:
gpt-4o-mini - override with
XRAY_LANGCHAIN_MODEL
Requirements:
pip install langchain langchain-openai openaiRun:
python examples/langchain_official/refinement_chain/langchain_official_example.pyThis live generation path requires OPENAI_API_KEY.
Replay through the CLI:
python -m cli.main examples/langchain_official/refinement_chain/captured_trace.jsonValidate JSON:
python -m json.tool examples/langchain_official/refinement_chain/captured_trace.jsonWhat X-Ray demonstrates:
- how a real LangChain refinement loop evolves across steps
- where early improvement gives way to diminishing structural change
- how the committed trace replays deterministically once saved
Committed artifacts:
Current observed X-Ray output for the committed fixture:
peak_step = 1waste = 83%- timeline ends in repeated refinement