- Production deployment: Deploy your integrated solution to LangSmith Deployment for scalable production use.
- Enhanced features: With Functional API, you can integrate your existing agents with persistence, streaming, short and long-term memory and more, with minimal changes to your existing code.
- Multi-agent systems: Build multi-agent systems where individual agents are built with different frameworks.
Prerequisites
- Python 3.9+
- Dependencies:
pip install strands-agents strands-agents-tools langgraph - AWS Credentials in your environment
1. Define Strands agent
Create a Strands Agent with pre-built tools.2. Use Functional API to deploy on LangSmith Deployment
Functional API allows you to intergate and deploy with frameworks other than LangChain. Functional API also provides the additional benefit to leverage other key features — persistence, memory, human-in-the-loop, and streaming — coupled with your existing agent, with minimal changes to your existing code. It uses two key building blocks:@entrypoint: Marks a function as the starting point of a workflow, encapsulating logic and managing execution flow, including handling long-running tasks and interrupts.@task: Represents a discrete unit of work, such as an API call or data processing step, that can be executed asynchronously within an entrypoint. Tasks return a future-like object that can be awaited or resolved synchronously.
3. Set up tracing with OpenTelemetry
In your environment variables, set up the following:If you’re self-hosting LangSmith, replace the
OTEL_EXPORTER_OTLP_ENDPOINT endpoint with your LangSmith API endpoint and append /api/v1/otel. For example: OTEL_EXPORTER_OTLP_ENDPOINT = "https://ai-company.com/api/v1/otel"Strand’s OTel tracing contains synchronous code. In this case, you may need to set
BG_JOB_ISOLATED_LOOPS=true to execute background runs in an isolated event loop separate from the serving API event loop.