Skip to content

Commit 268e6d6

Browse files
fix(core): add comment why we remove the timeout comment (langchain-ai#9603)
1 parent 127b4bf commit 268e6d6

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

libs/langchain-core/src/runnables/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ export function ensureConfig<CallOptions extends RunnableConfig>(
196196
} else {
197197
empty.signal = timeoutSignal;
198198
}
199+
200+
/**
201+
* We are deleting the timeout key for the following reasons:
202+
* - Idempotent normalization: ensureConfig may be called multiple times down the stack. If timeout remains,
203+
* each call would synthesize new timeout signals and combine them, changing the effective timeout unpredictably.
204+
* - Single enforcement path: downstream code relies on signal to enforce cancellation. Leaving timeout means two
205+
* competing mechanisms (numeric timeout and signal) can be applied, sometimes with different semantics.
206+
* - Propagation to children: pickRunnableConfigKeys would keep forwarding timeout to nested runnables, causing
207+
* repeated re-normalization and stacked timeouts.
208+
* - Backward compatibility: a lot of components and tests assume ensureConfig removes timeout post-normalization;
209+
* changing that would be a breaking change.
210+
*/
199211
delete empty.timeout;
200212
}
201213
return empty as CallOptions;

libs/langchain-core/src/tracers/tests/__snapshots__/langchain_tracer.test.ts.snap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,12 @@ exports[`LangChainTracer payload snapshots for run create and update 3`] = `
109109
"inputs": {
110110
"input": "test input",
111111
},
112-
"name": "RunnableLambda",
113112
"outputs": {
114113
"output": "processed: test input",
115114
},
116115
"parent_run_id": Any<String>,
117116
"reference_example_id": undefined,
118-
"run_type": "chain",
119117
"session_name": Any<String>,
120-
"start_time": Any<String>,
121118
"tags": [],
122119
"trace_id": Any<String>,
123120
}
@@ -144,15 +141,12 @@ exports[`LangChainTracer payload snapshots for run create and update 4`] = `
144141
"inputs": {
145142
"input": "test input",
146143
},
147-
"name": "RunnableLambda",
148144
"outputs": {
149145
"output": "parent: processed: test input",
150146
},
151147
"parent_run_id": undefined,
152148
"reference_example_id": undefined,
153-
"run_type": "chain",
154149
"session_name": Any<String>,
155-
"start_time": Any<String>,
156150
"tags": [],
157151
"trace_id": Any<String>,
158152
}

libs/langchain-core/src/tracers/tests/langchain_tracer.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ test("LangChainTracer payload snapshots for run create and update", async () =>
7474
session_name: expect.any(String),
7575
dotted_order: expect.any(String),
7676
end_time: expect.any(Number),
77-
start_time: expect.any(String),
7877
events: expect.arrayContaining([
7978
expect.objectContaining({
8079
time: expect.any(String),
@@ -93,7 +92,6 @@ test("LangChainTracer payload snapshots for run create and update", async () =>
9392
time: expect.any(String),
9493
}),
9594
]),
96-
start_time: expect.any(String),
9795
trace_id: expect.any(String),
9896
});
9997
});

0 commit comments

Comments
 (0)