temporalio-langsmith 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 temporal.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,271 @@
1
+ Metadata-Version: 2.4
2
+ Name: temporalio-langsmith
3
+ Version: 0.1.0
4
+ Summary: Temporal integration for langsmith
5
+ Author: Temporal Technologies Inc
6
+ Author-email: Temporal Technologies Inc <sdk@temporal.io>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Typing :: Typed
16
+ Requires-Dist: temporalio>=1.34.0,<2
17
+ Requires-Dist: langsmith>=0.7.34,<0.13
18
+ Requires-Dist: langchain-core>=0.3.0
19
+ Requires-Dist: nexus-rpc==1.4.0
20
+ Requires-Python: >=3.10
21
+ Project-URL: Homepage, https://github.com/temporalio/ai-integrations/tree/main/python/langsmith
22
+ Project-URL: Repository, https://github.com/temporalio/ai-integrations
23
+ Project-URL: Documentation, https://docs.temporal.io/develop/python/integrations/langsmith
24
+ Description-Content-Type: text/markdown
25
+
26
+ # LangSmith Plugin for Temporal Python SDK
27
+
28
+ > Release stage: [Public Preview](https://docs.temporal.io/develop/python/integrations/langsmith).
29
+
30
+ This Temporal [Plugin](https://docs.temporal.io/develop/plugins-guide) allows your [LangSmith](https://smith.langchain.com/) traces to work within Temporal Workflows. It propagates trace context across Worker boundaries so that `@traceable` calls, LLM invocations, and Temporal operations show up in a single connected trace, and ensures that replaying does not generate duplicate traces.
31
+
32
+ ## Quick Start
33
+
34
+ Install the Temporal LangSmith plugin:
35
+
36
+ ```bash
37
+ uv add temporalio-langsmith
38
+ ```
39
+
40
+ Register the Plugin on your Temporal Client. You need it on both the Client (starter) side and the Workers:
41
+
42
+ ```python
43
+ from temporalio.client import Client
44
+ from temporalio.langsmith import LangSmithPlugin
45
+
46
+ client = await Client.connect(
47
+ "localhost:7233",
48
+ plugins=[LangSmithPlugin(project_name="my-project")],
49
+ )
50
+ ```
51
+
52
+ Once that's set up, any `@traceable` function inside your Workflows and Activities will show up in LangSmith with correct parent-child relationships, even across Worker boundaries.
53
+
54
+ ## Example: AI Chatbot
55
+
56
+ A conversational chatbot using OpenAI, orchestrated by a Temporal Workflow. The Workflow stays alive waiting for user messages via Signals, and dispatches each message to an Activity that calls the LLM.
57
+
58
+ ### Activity (Wraps the LLM Call)
59
+
60
+ ```python
61
+ from langsmith import traceable
62
+
63
+ @traceable(name="Call OpenAI", run_type="chain")
64
+ @activity.defn
65
+ async def call_openai(request: OpenAIRequest) -> Response:
66
+ client = wrap_openai(AsyncOpenAI()) # This is a traced langsmith function
67
+ return await client.responses.create(
68
+ model=request.model,
69
+ input=request.input,
70
+ instructions=request.instructions,
71
+ )
72
+ ```
73
+
74
+ ### Workflow (Orchestrates the Conversation)
75
+
76
+ ```python
77
+ @workflow.defn
78
+ class ChatbotWorkflow:
79
+ @workflow.run
80
+ async def run(self) -> str:
81
+ # @traceable works inside Workflows — fully replay-safe
82
+ now = workflow.now().strftime("%b %d %H:%M")
83
+ return await traceable(
84
+ name=f"Session {now}", run_type="chain",
85
+ )(self._run_with_trace)()
86
+
87
+ async def _run_with_trace(self) -> str:
88
+ while not self._done:
89
+ await workflow.wait_condition(
90
+ lambda: self._pending_message is not None or self._done
91
+ )
92
+ if self._done:
93
+ break
94
+
95
+ message = self._pending_message
96
+ self._pending_message = None
97
+
98
+ @traceable(name=f"Query: {message[:60]}", run_type="chain")
99
+ async def _query(msg: str) -> str:
100
+ response = await workflow.execute_activity(
101
+ call_openai,
102
+ OpenAIRequest(model="gpt-4o-mini", input=msg),
103
+ start_to_close_timeout=timedelta(seconds=60),
104
+ )
105
+ return response.output_text
106
+
107
+ self._last_response = await _query(message)
108
+
109
+ return "Session ended."
110
+ ```
111
+
112
+ ### Worker
113
+
114
+ ```python
115
+ client = await Client.connect(
116
+ "localhost:7233",
117
+ plugins=[LangSmithPlugin(project_name="chatbot")],
118
+ )
119
+
120
+ worker = Worker(
121
+ client,
122
+ task_queue="chatbot",
123
+ workflows=[ChatbotWorkflow],
124
+ activities=[call_openai],
125
+ )
126
+ await worker.run()
127
+ ```
128
+
129
+ ### What you see in LangSmith
130
+
131
+ With the default configuration (`add_temporal_runs=False`), the trace contains only your application logic:
132
+
133
+ ```
134
+ Session Apr 03 14:30
135
+ Query: "What's the weather in NYC?"
136
+ Call OpenAI
137
+ openai.responses.create (auto-traced by wrap_openai)
138
+ ```
139
+
140
+ An actual look at the LangSmith UI:
141
+
142
+ ![Screenshot: LangSmith trace tree with add_temporal_runs=False showing clean application-only hierarchy](images/langsmith-no-temporal.png)
143
+
144
+ ## `add_temporal_runs` — Temporal Operation Visibility
145
+
146
+ By default, `add_temporal_runs` is `False` and only your `@traceable` application logic appears in traces. Setting it to `True` also adds Temporal operations (StartWorkflow, RunWorkflow, StartActivity, RunActivity, etc.):
147
+
148
+ ```python
149
+ plugins=[LangSmithPlugin(project_name="my-project", add_temporal_runs=True)]
150
+ ```
151
+
152
+ This adds Temporal operation nodes to the trace tree so that the orchestration layer is visible alongside your application logic. If the caller wraps `start_workflow` in a `@traceable` function, the full trace looks like:
153
+
154
+ ```
155
+ Ask Chatbot # @traceable wrapper around client.start_workflow
156
+ StartWorkflow:ChatbotWorkflow
157
+ RunWorkflow:ChatbotWorkflow
158
+ Session Apr 03 14:30
159
+ Query: "What's the weather in NYC?"
160
+ StartActivity:call_openai
161
+ RunActivity:call_openai
162
+ Call OpenAI
163
+ openai.responses.create
164
+ ```
165
+
166
+ Note: `StartFoo` and `RunFoo` appear as siblings. The start is the short-lived outbound RPC that enqueues work on a task queue and completes immediately, and the run is the actual execution which may be delayed and may take much longer.
167
+
168
+ An actual look at the LangSmith UI:
169
+
170
+ ![Screenshot: LangSmith trace tree with add_temporal_runs=True showing Temporal operation nodes](images/langsmith-with-temporal.png)
171
+
172
+ And here is a waterfall view of the Workflow in Temporal UI:
173
+
174
+ ![Screenshot: Temporal UI showing the corresponding Workflow execution](images/temporal-ui.png)
175
+
176
+ ## Migrating Existing LangSmith Code to Temporal
177
+
178
+ If you already have code with LangSmith tracing, you should be able to move it into a Temporal Workflow and keep the same trace hierarchy. The Plugin handles sandbox restrictions and context propagation behind the scenes, so anything that was traceable before should remain traceable after the move. More details below:
179
+
180
+ ### Where `@traceable` Works
181
+
182
+ The Plugin allows `@traceable` to work inside Temporal's deterministic Workflow sandbox, where it normally can't run. Note that `@traceable` on an Activity fires on each retry.
183
+
184
+ | Location | Works? | Notes |
185
+ |-------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
186
+ | Inside Workflow methods | Yes | Traces called from inside `@workflow.run`, `@workflow.signal`, etc.; can trace sync and async methods |
187
+ | Inside Activity methods | Yes | Traces called from inside `@activity.defn`; can trace sync and async methods |
188
+ | On `@activity.defn` functions | Yes | Must stack `@traceable` decorator on top of `@activity.defn` decorator for correct functionality. *Note*: This trace fires on every retry; see [Wrapping Retriable Steps section](#example-wrapping-retriable-steps-in-a-trace) for more info |
189
+ | On `@workflow.defn` classes | No | Use `@traceable` inside `@workflow.run` instead. Decorating the workflow class or the `@workflow.run` function is not supported. |
190
+
191
+ ## Replay Safety
192
+
193
+ Temporal Workflows are deterministic and get replayed from event history on recovery. The Plugin accounts for this by injecting replay-safe data into your traceable runs:
194
+
195
+ - **No duplicate traces on replay.** Run IDs are derived deterministically from the Workflow's random seed, so replayed operations produce the same IDs and LangSmith deduplicates them.
196
+ - **No non-deterministic calls.** The Plugin injects metadata using `workflow.now()` for timestamps and `workflow.random()` for UUIDs instead of `datetime.now()` and `uuid4()`.
197
+ - **Background I/O stays outside the sandbox.** LangSmith HTTP calls to the server are submitted to a background thread pool that doesn't interfere with the deterministic Workflow execution.
198
+
199
+ You don't need to do anything special for this. Your `@traceable` functions behave the same whether it's a fresh execution or a replay.
200
+
201
+ ### Example: Worker Crash Mid-Workflow
202
+
203
+ ```
204
+ 1. Workflow starts, executes Activity A -> trace appears in LangSmith
205
+ 2. Worker crashes during Activity B
206
+ 3. New Worker picks up the Workflow
207
+ 4. Workflow replays Activity A (skips execution) -> NO duplicate trace
208
+ 5. Workflow executes Activity B (new work) -> new trace appears
209
+ ```
210
+
211
+ As you can see in the UI example below, a crash in the `Call OpenAI` activity didn't cause earlier traces to be duplicated:
212
+
213
+ ![Screenshot: LangSmith showing a Workflow trace that survived a Worker restart with no duplicate runs](images/langsmith-with-crash-no-temporal.png)
214
+
215
+ ### Example: Wrapping Retriable Steps in a Trace
216
+
217
+ Since Temporal retries failed Activities, you can use an outer `@traceable` to group the attempts together:
218
+
219
+ ```python
220
+ @traceable(name="Call OpenAI", run_type="llm")
221
+ @activity.defn
222
+ async def call_openai(...):
223
+ ...
224
+
225
+ @traceable(name="my_step", run_type="chain")
226
+ async def my_step(message: str) -> str:
227
+ return await workflow.execute_activity(
228
+ call_openai,
229
+ ...
230
+ )
231
+ ```
232
+
233
+ This groups everything under one run:
234
+ ```
235
+ my_step
236
+ Call OpenAI # first attempt
237
+ openai.responses.create
238
+ Call OpenAI # retry
239
+ openai.responses.create
240
+ ```
241
+
242
+ ## Context Propagation
243
+
244
+ The Plugin propagates trace context across process boundaries (Client -> Workflow -> Activity -> Child Workflow -> Nexus) via Temporal headers. You don't need to pass any context manually.
245
+
246
+ ```
247
+ Client Process Worker Process (Workflow) Worker Process (Activity)
248
+ ───────────── ────────────────────────── ─────────────────────────
249
+ @traceable("my workflow")
250
+ start_workflow ──headers──> RunWorkflow
251
+ @traceable("session")
252
+ execute_activity ──headers──> RunActivity
253
+ @traceable("Call OpenAI")
254
+ openai.create(...)
255
+ ```
256
+
257
+ ## API Reference
258
+
259
+ ### `LangSmithPlugin`
260
+
261
+ ```python
262
+ LangSmithPlugin(
263
+ client=None, # langsmith.Client instance (auto-created if None)
264
+ project_name=None, # LangSmith project name
265
+ add_temporal_runs=False, # Show Temporal operation nodes in traces
266
+ default_metadata=None, # Custom metadata attached to all LangSmith traces (https://docs.smith.langchain.com/observability/how_to_guides/add_metadata_tags)
267
+ default_tags=None, # Custom tags attached to all LangSmith traces (see link above)
268
+ )
269
+ ```
270
+
271
+ We recommend registering the Plugin on both the Client and all Workers. Strictly speaking, you only need it on the sides that produce traces, but adding it everywhere avoids surprises with context propagation. The Client and Worker don't need to share the same configuration — for example, they can use different `add_temporal_runs` settings.
@@ -0,0 +1,246 @@
1
+ # LangSmith Plugin for Temporal Python SDK
2
+
3
+ > Release stage: [Public Preview](https://docs.temporal.io/develop/python/integrations/langsmith).
4
+
5
+ This Temporal [Plugin](https://docs.temporal.io/develop/plugins-guide) allows your [LangSmith](https://smith.langchain.com/) traces to work within Temporal Workflows. It propagates trace context across Worker boundaries so that `@traceable` calls, LLM invocations, and Temporal operations show up in a single connected trace, and ensures that replaying does not generate duplicate traces.
6
+
7
+ ## Quick Start
8
+
9
+ Install the Temporal LangSmith plugin:
10
+
11
+ ```bash
12
+ uv add temporalio-langsmith
13
+ ```
14
+
15
+ Register the Plugin on your Temporal Client. You need it on both the Client (starter) side and the Workers:
16
+
17
+ ```python
18
+ from temporalio.client import Client
19
+ from temporalio.langsmith import LangSmithPlugin
20
+
21
+ client = await Client.connect(
22
+ "localhost:7233",
23
+ plugins=[LangSmithPlugin(project_name="my-project")],
24
+ )
25
+ ```
26
+
27
+ Once that's set up, any `@traceable` function inside your Workflows and Activities will show up in LangSmith with correct parent-child relationships, even across Worker boundaries.
28
+
29
+ ## Example: AI Chatbot
30
+
31
+ A conversational chatbot using OpenAI, orchestrated by a Temporal Workflow. The Workflow stays alive waiting for user messages via Signals, and dispatches each message to an Activity that calls the LLM.
32
+
33
+ ### Activity (Wraps the LLM Call)
34
+
35
+ ```python
36
+ from langsmith import traceable
37
+
38
+ @traceable(name="Call OpenAI", run_type="chain")
39
+ @activity.defn
40
+ async def call_openai(request: OpenAIRequest) -> Response:
41
+ client = wrap_openai(AsyncOpenAI()) # This is a traced langsmith function
42
+ return await client.responses.create(
43
+ model=request.model,
44
+ input=request.input,
45
+ instructions=request.instructions,
46
+ )
47
+ ```
48
+
49
+ ### Workflow (Orchestrates the Conversation)
50
+
51
+ ```python
52
+ @workflow.defn
53
+ class ChatbotWorkflow:
54
+ @workflow.run
55
+ async def run(self) -> str:
56
+ # @traceable works inside Workflows — fully replay-safe
57
+ now = workflow.now().strftime("%b %d %H:%M")
58
+ return await traceable(
59
+ name=f"Session {now}", run_type="chain",
60
+ )(self._run_with_trace)()
61
+
62
+ async def _run_with_trace(self) -> str:
63
+ while not self._done:
64
+ await workflow.wait_condition(
65
+ lambda: self._pending_message is not None or self._done
66
+ )
67
+ if self._done:
68
+ break
69
+
70
+ message = self._pending_message
71
+ self._pending_message = None
72
+
73
+ @traceable(name=f"Query: {message[:60]}", run_type="chain")
74
+ async def _query(msg: str) -> str:
75
+ response = await workflow.execute_activity(
76
+ call_openai,
77
+ OpenAIRequest(model="gpt-4o-mini", input=msg),
78
+ start_to_close_timeout=timedelta(seconds=60),
79
+ )
80
+ return response.output_text
81
+
82
+ self._last_response = await _query(message)
83
+
84
+ return "Session ended."
85
+ ```
86
+
87
+ ### Worker
88
+
89
+ ```python
90
+ client = await Client.connect(
91
+ "localhost:7233",
92
+ plugins=[LangSmithPlugin(project_name="chatbot")],
93
+ )
94
+
95
+ worker = Worker(
96
+ client,
97
+ task_queue="chatbot",
98
+ workflows=[ChatbotWorkflow],
99
+ activities=[call_openai],
100
+ )
101
+ await worker.run()
102
+ ```
103
+
104
+ ### What you see in LangSmith
105
+
106
+ With the default configuration (`add_temporal_runs=False`), the trace contains only your application logic:
107
+
108
+ ```
109
+ Session Apr 03 14:30
110
+ Query: "What's the weather in NYC?"
111
+ Call OpenAI
112
+ openai.responses.create (auto-traced by wrap_openai)
113
+ ```
114
+
115
+ An actual look at the LangSmith UI:
116
+
117
+ ![Screenshot: LangSmith trace tree with add_temporal_runs=False showing clean application-only hierarchy](images/langsmith-no-temporal.png)
118
+
119
+ ## `add_temporal_runs` — Temporal Operation Visibility
120
+
121
+ By default, `add_temporal_runs` is `False` and only your `@traceable` application logic appears in traces. Setting it to `True` also adds Temporal operations (StartWorkflow, RunWorkflow, StartActivity, RunActivity, etc.):
122
+
123
+ ```python
124
+ plugins=[LangSmithPlugin(project_name="my-project", add_temporal_runs=True)]
125
+ ```
126
+
127
+ This adds Temporal operation nodes to the trace tree so that the orchestration layer is visible alongside your application logic. If the caller wraps `start_workflow` in a `@traceable` function, the full trace looks like:
128
+
129
+ ```
130
+ Ask Chatbot # @traceable wrapper around client.start_workflow
131
+ StartWorkflow:ChatbotWorkflow
132
+ RunWorkflow:ChatbotWorkflow
133
+ Session Apr 03 14:30
134
+ Query: "What's the weather in NYC?"
135
+ StartActivity:call_openai
136
+ RunActivity:call_openai
137
+ Call OpenAI
138
+ openai.responses.create
139
+ ```
140
+
141
+ Note: `StartFoo` and `RunFoo` appear as siblings. The start is the short-lived outbound RPC that enqueues work on a task queue and completes immediately, and the run is the actual execution which may be delayed and may take much longer.
142
+
143
+ An actual look at the LangSmith UI:
144
+
145
+ ![Screenshot: LangSmith trace tree with add_temporal_runs=True showing Temporal operation nodes](images/langsmith-with-temporal.png)
146
+
147
+ And here is a waterfall view of the Workflow in Temporal UI:
148
+
149
+ ![Screenshot: Temporal UI showing the corresponding Workflow execution](images/temporal-ui.png)
150
+
151
+ ## Migrating Existing LangSmith Code to Temporal
152
+
153
+ If you already have code with LangSmith tracing, you should be able to move it into a Temporal Workflow and keep the same trace hierarchy. The Plugin handles sandbox restrictions and context propagation behind the scenes, so anything that was traceable before should remain traceable after the move. More details below:
154
+
155
+ ### Where `@traceable` Works
156
+
157
+ The Plugin allows `@traceable` to work inside Temporal's deterministic Workflow sandbox, where it normally can't run. Note that `@traceable` on an Activity fires on each retry.
158
+
159
+ | Location | Works? | Notes |
160
+ |-------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
161
+ | Inside Workflow methods | Yes | Traces called from inside `@workflow.run`, `@workflow.signal`, etc.; can trace sync and async methods |
162
+ | Inside Activity methods | Yes | Traces called from inside `@activity.defn`; can trace sync and async methods |
163
+ | On `@activity.defn` functions | Yes | Must stack `@traceable` decorator on top of `@activity.defn` decorator for correct functionality. *Note*: This trace fires on every retry; see [Wrapping Retriable Steps section](#example-wrapping-retriable-steps-in-a-trace) for more info |
164
+ | On `@workflow.defn` classes | No | Use `@traceable` inside `@workflow.run` instead. Decorating the workflow class or the `@workflow.run` function is not supported. |
165
+
166
+ ## Replay Safety
167
+
168
+ Temporal Workflows are deterministic and get replayed from event history on recovery. The Plugin accounts for this by injecting replay-safe data into your traceable runs:
169
+
170
+ - **No duplicate traces on replay.** Run IDs are derived deterministically from the Workflow's random seed, so replayed operations produce the same IDs and LangSmith deduplicates them.
171
+ - **No non-deterministic calls.** The Plugin injects metadata using `workflow.now()` for timestamps and `workflow.random()` for UUIDs instead of `datetime.now()` and `uuid4()`.
172
+ - **Background I/O stays outside the sandbox.** LangSmith HTTP calls to the server are submitted to a background thread pool that doesn't interfere with the deterministic Workflow execution.
173
+
174
+ You don't need to do anything special for this. Your `@traceable` functions behave the same whether it's a fresh execution or a replay.
175
+
176
+ ### Example: Worker Crash Mid-Workflow
177
+
178
+ ```
179
+ 1. Workflow starts, executes Activity A -> trace appears in LangSmith
180
+ 2. Worker crashes during Activity B
181
+ 3. New Worker picks up the Workflow
182
+ 4. Workflow replays Activity A (skips execution) -> NO duplicate trace
183
+ 5. Workflow executes Activity B (new work) -> new trace appears
184
+ ```
185
+
186
+ As you can see in the UI example below, a crash in the `Call OpenAI` activity didn't cause earlier traces to be duplicated:
187
+
188
+ ![Screenshot: LangSmith showing a Workflow trace that survived a Worker restart with no duplicate runs](images/langsmith-with-crash-no-temporal.png)
189
+
190
+ ### Example: Wrapping Retriable Steps in a Trace
191
+
192
+ Since Temporal retries failed Activities, you can use an outer `@traceable` to group the attempts together:
193
+
194
+ ```python
195
+ @traceable(name="Call OpenAI", run_type="llm")
196
+ @activity.defn
197
+ async def call_openai(...):
198
+ ...
199
+
200
+ @traceable(name="my_step", run_type="chain")
201
+ async def my_step(message: str) -> str:
202
+ return await workflow.execute_activity(
203
+ call_openai,
204
+ ...
205
+ )
206
+ ```
207
+
208
+ This groups everything under one run:
209
+ ```
210
+ my_step
211
+ Call OpenAI # first attempt
212
+ openai.responses.create
213
+ Call OpenAI # retry
214
+ openai.responses.create
215
+ ```
216
+
217
+ ## Context Propagation
218
+
219
+ The Plugin propagates trace context across process boundaries (Client -> Workflow -> Activity -> Child Workflow -> Nexus) via Temporal headers. You don't need to pass any context manually.
220
+
221
+ ```
222
+ Client Process Worker Process (Workflow) Worker Process (Activity)
223
+ ───────────── ────────────────────────── ─────────────────────────
224
+ @traceable("my workflow")
225
+ start_workflow ──headers──> RunWorkflow
226
+ @traceable("session")
227
+ execute_activity ──headers──> RunActivity
228
+ @traceable("Call OpenAI")
229
+ openai.create(...)
230
+ ```
231
+
232
+ ## API Reference
233
+
234
+ ### `LangSmithPlugin`
235
+
236
+ ```python
237
+ LangSmithPlugin(
238
+ client=None, # langsmith.Client instance (auto-created if None)
239
+ project_name=None, # LangSmith project name
240
+ add_temporal_runs=False, # Show Temporal operation nodes in traces
241
+ default_metadata=None, # Custom metadata attached to all LangSmith traces (https://docs.smith.langchain.com/observability/how_to_guides/add_metadata_tags)
242
+ default_tags=None, # Custom tags attached to all LangSmith traces (see link above)
243
+ )
244
+ ```
245
+
246
+ We recommend registering the Plugin on both the Client and all Workers. Strictly speaking, you only need it on the sides that produce traces, but adding it everywhere avoids surprises with context propagation. The Client and Worker don't need to share the same configuration — for example, they can use different `add_temporal_runs` settings.
@@ -0,0 +1,129 @@
1
+ [project]
2
+ name = "temporalio-langsmith"
3
+ version = "0.1.0"
4
+ description = "Temporal integration for langsmith"
5
+ requires-python = ">=3.10"
6
+ readme = "README.md"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 4 - Beta",
11
+ "Programming Language :: Python :: 3.10",
12
+ "Programming Language :: Python :: 3.11",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Typing :: Typed",
17
+ ]
18
+ dependencies = [
19
+ "temporalio>=1.34.0,<2",
20
+ "langsmith>=0.7.34,<0.13",
21
+ "langchain-core>=0.3.0",
22
+ "nexus-rpc==1.4.0",
23
+ ]
24
+
25
+ [[project.authors]]
26
+ name = "Temporal Technologies Inc"
27
+ email = "sdk@temporal.io"
28
+
29
+ [project.optional-dependencies]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/temporalio/ai-integrations/tree/main/python/langsmith"
33
+ Repository = "https://github.com/temporalio/ai-integrations"
34
+ Documentation = "https://docs.temporal.io/develop/python/integrations/langsmith"
35
+
36
+ [build-system]
37
+ requires = ["uv_build>=0.12.5,<0.13"]
38
+ build-backend = "uv_build"
39
+
40
+ [tool.uv]
41
+ default-groups = ["dev"]
42
+ required-version = ">=0.12.5,<0.13"
43
+ exclude-newer = "2 weeks"
44
+ link-mode = "copy"
45
+
46
+ [tool.uv.build-backend]
47
+ module-name = "temporalio.langsmith"
48
+
49
+ [tool.uv.exclude-newer-package]
50
+ temporalio = false
51
+
52
+ [[tool.uv.cache-keys]]
53
+ file = "pyproject.toml"
54
+
55
+ [[tool.uv.cache-keys]]
56
+ file = "README.md"
57
+
58
+ [[tool.uv.cache-keys]]
59
+ file = "src/**/*"
60
+
61
+ [tool.pytest.ini_options]
62
+ asyncio_mode = "auto"
63
+ markers = ["requires_local_server: test requires the local Temporal development server"]
64
+ log_level = "DEBUG"
65
+ log_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
66
+ testpaths = ["tests"]
67
+ timeout = 60
68
+ timeout_func_only = true
69
+ filterwarnings = [
70
+ "error::temporalio.workflow.UnfinishedUpdateHandlersWarning",
71
+ "error::temporalio.workflow.UnfinishedSignalHandlersWarning",
72
+ "ignore::pytest.PytestDeprecationWarning",
73
+ "ignore::DeprecationWarning",
74
+ ]
75
+
76
+ [tool.mypy]
77
+ files = [
78
+ "src",
79
+ "tests",
80
+ ]
81
+ mypy_path = "src"
82
+ namespace_packages = true
83
+ explicit_package_bases = true
84
+ check_untyped_defs = true
85
+ ignore_missing_imports = true
86
+
87
+ [tool.pyright]
88
+ extends = "../_shared/pyrightconfig.json"
89
+ include = [
90
+ "src",
91
+ "tests",
92
+ ]
93
+
94
+ [[tool.pyright.executionEnvironments]]
95
+ root = "."
96
+ extraPaths = ["src"]
97
+
98
+ [tool.pydocstyle]
99
+ convention = "google"
100
+ add_ignore = [
101
+ "D205",
102
+ "D415",
103
+ ]
104
+
105
+ [tool.ruff]
106
+ extend = "../_shared/ruff.toml"
107
+ src = [
108
+ ".",
109
+ "src",
110
+ ]
111
+
112
+ [tool.ruff.lint.isort]
113
+ known-third-party = ["langsmith"]
114
+
115
+ [dependency-groups]
116
+ dev = [
117
+ "pyright==1.1.403",
118
+ "basedpyright==1.34.0",
119
+ "mypy==1.18.2",
120
+ "ruff>=0.15.12,<0.16",
121
+ "pydocstyle>=6.3,<7",
122
+ "pytest~=9.0",
123
+ "pytest-asyncio>=0.21.2,<0.22",
124
+ "pytest-timeout~=2.2",
125
+ "pytest-xdist>=3.6,<4",
126
+ "pytest-pretty>=1.3",
127
+ "pytest-rerunfailures>=16.1",
128
+ "tomli>=2.0; python_version < '3.11'",
129
+ ]