Skip to main content
Version: ChatLead

LangSmith Integration Feature Update


Group Billing

Author(s)

  • Alapan Das
  • ...

Last Updated Date

[2025-08-20]


SRS References


Version History

VersionDateChangesAuthor
1.02025-08-20Initial draftAlapan Das
............

Overview

This update introduces LangSmith tracing and analytics to the BotProxyService project, enabling advanced observability for agent workflows in both the botworker and crawler services. LangSmith provides detailed traces, tool usage analytics, and error reporting for all agent interactions, helping developers monitor, debug, and optimize LLM-powered workflows.


Key Features

  • LangSmith Tracing: All agent executions are traced and sent to LangSmith for analysis.
  • Project Tagging: Traces are tagged with the project name (botproxyservice or botproxy) for easy filtering.
  • Environment Configuration: All LangSmith credentials and settings are managed via Docker Compose environment variables.
  • Optional Tracing: LangSmith tracing can be enabled or disabled by commenting/uncommenting the relevant code in executor.py.
  • Error Handling: If authentication fails, agent execution continues without LangSmith tracing.

How It Works

  • The agent executor initializes a LangSmith tracer using credentials from environment variables.
  • All agent runs, tool calls, and errors are sent to LangSmith for visualization and analysis.
  • Tracing is enabled for both botworker and crawler containers.

Configuration

Docker Compose

Add the following environment variables to your docker-compose.yml or docker-compose.override.yml for both botworker and crawler:

environment:
- LANGSMITH_API_KEY=<your-langsmith-api-key>
- LANGSMITH_PROJECT=botproxy
- LANGSMITH_ENDPOINT=https://api.smith.langchain.com

Example:

environment:
- LANGSMITH_API_KEY=<your-langsmith-api-key>
- LANGSMITH_PROJECT=botproxy
- LANGSMITH_ENDPOINT=https://api.smith.langchain.com

Python Code

LangSmith tracing is initialized in bot_worker/app/agent/executor.py:

# from langsmith import Client
# from langchain.callbacks.tracers.langchain import LangChainTracer

# try:
# langsmith_client = Client()
# tracer = LangChainTracer(
# project_name="botproxy",
# client=langsmith_client
# )
# callbacks.append(tracer)
# print("LangSmith tracing enabled successfully")
# except Exception as e:
# print(f"Failed to initialize LangSmith tracing: {str(e)}")

To disable tracing, comment out the above code.


Usage

  1. Set your LangSmith API key and project name in your Docker Compose files.
  2. Deploy your containers as usual.
  3. View traces and analytics in your LangSmith dashboard at smith.langchain.com.

Troubleshooting

  • 401 Unauthorized Error: Ensure your API key is correct and active.
  • No Traces in Dashboard: Make sure the environment variables are set and the tracer code is not commented out.
  • Disable Tracing: Simply comment out the LangSmith tracer initialization in executor.py.

References


Contact

For questions or support, contact the BotProxyService team via [channel/email].