Overview
Integrate Freeplay with LangGraph to add observability, prompt management, and evaluation capabilities to your LangGraph applications. This comprehensive guide covers everything from basic setup to advanced agent workflows with state management, streaming, and human-in-the-loop patterns.Prerequisites
Before you begin, make sure you have:- A Freeplay account with an active project
- Python 3.10 or higher installed
- Basic familiarity with LangGraph and LangChain
Quick Start with Observability
Installation
Install the Freeplay LangGraph SDK along with your preferred LLM provider. For advanced use, please refer to the documentation on PyPi.Configuration
Set Up Your Credentials
Configure your Freeplay credentials using environment variables:Initialize the SDK
Create aFreeplayLangGraph instance in your application:
Note: It is recommended to manage your prompts within Freeplay to support
better prompt development lifecycle. Continue following this guide to get your
prompts configured within LangGraph.
Prompt Management
Freeplay’s integration requires that you have your prompts configured in Freeplay. By default,FreeplayLangGraph fetches prompts from the Freeplay API. This requires you to have prompts configured in Freeplay for use. To learn more, see our Prompt Management guide here. Once configured you will need the prompt names for use in the code.
Managing prompts in Freeplay separates your prompt engineering workflow from your LangGraph application. Instead of hardcoding prompts in your agent code, your team can iterate on prompt templates, test different versions , new models and deploy changes through Freeplay without modifying or redeploying your LangGraph application. This enables your team to test agent behavior, maintain different prompt versions across environments (development, staging, production), and experiment with variations.
Optional - Prompt Bundling
Once your prompts are saved in Freeplay, you can use bundled prompts stored locally with your application, you can provide a custom template resolver:Core Concepts
Freeplay provides two primary ways to work with LangGraph:create_agent()- For building full LangGraph agents with tool calling, ReAct loops, and state managementinvoke()- For simple, stateless LLM invocations when you don’t need agent capabilities
create_agent() when you need the full power of LangGraph’s agent framework, and invoke() for simpler use cases.
Building LangGraph Agents
Thecreate_agent method provides full support for LangGraph’s agent capabilities including the ReAct loop, tool calling, state management, middleware, and streaming.
Basic Agent Creation
Create an agent that uses a Freeplay-hosted prompt with automatic model instantiation. You have the ability to pass variables at the creation and invocation of the agent, both are optional depending on your flow:create_agent gives you access to LangGraph’s full agent capabilities, including tool calling with the ReAct loop, state persistence, and advanced execution control.
Adding Tools
Bind LangChain tools to your agent for agentic workflows. The agent automatically decides when to call tools:Conversation History
Maintain conversation context across multiple turns with conversation history:Structured Output
Get structured, typed responses from your agents usingToolStrategy or ProviderStrategy:
Automatic Observability
Once initialized, the Freeplay SDK automatically instruments your LangGraph application with OpenTelemetry. This means every LangChain and LangGraph operation is traced and sent to Freeplay without any additional code.What Gets Tracked
Freeplay automatically captures:- Prompt invocations: Template, variables, and generated content
- Model calls: Provider, model name, tokens used, latency
- Tool executions: Which tools were called and their results
- Agent flows: Multi-step reasoning and decision paths
- Conversation flows: Multi-turn interactions and state transitions
- Errors and exceptions: Failed invocations with stack traces
- Metadata: Test run IDs, test case IDs, environment names, and custom tags
RunnableBindingBase pattern, ensuring comprehensive observability without manual instrumentation.
Viewing Traces
You can view all of this data in the Freeplay dashboard, making it easy to:- Debug issues and understand failure patterns
- Optimize performance and reduce latency
- Understand how your application behaves in production
- Track token usage and costs across environments
- Measure impact of prompt changes over time
Simple Prompt Invocations
For simpler use cases that don’t require the full agent loop, use theinvoke method. This is ideal for one-off completions, quick classifications, or any scenario where you don’t need agent state management or the ReAct loop.
Basic Invocation
Call a Freeplay-hosted prompt with automatic model instantiation:invoke gives you quick access to Freeplay-managed prompts without the overhead of agent state or tool calling. This is perfect for classification tasks, content generation, or any stateless LLM operation.

