Skip to main content
This guide shows you how to use Functional API to deploy a Strands Agent on LangSmith Deployment and set up tracing for LangSmith Observability. You can follow the same approach with other frameworks like CrewAI, AutoGen, Google ADK. Using Functional API and deploying to LangSmith Deployment provides several benefits:

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 prebuilt tools.

2. Use Functional API to deploy on LangSmith Deployment

Functional API allows you to integrate 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.
In your main agent, set up the following:

4. Prepare for deployment

From here, to deploy to LangSmith, create a file structure like the following:
To deploy your agent, follow the Deploy to cloud guide.