Skip to content

Commit 1b40c3f

Browse files
fix(core): tracing perf improvements (#8176)
1 parent a620df8 commit 1b40c3f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

langchain-core/src/callbacks/manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ export class CallbackManager
12091209
} else {
12101210
callbackManager = inheritableHandlers;
12111211
}
1212+
12121213
callbackManager = callbackManager.copy(
12131214
Array.isArray(localHandlers)
12141215
? localHandlers.map(ensureHandler)

langchain-core/src/tracers/tracer_langchain.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,15 @@ export class LangChainTracer
192192

193193
static getTraceableRunTree(): RunTree | undefined {
194194
try {
195-
return getCurrentRunTree();
195+
return (
196+
// The type cast here provides forward compatibility. Old versions of LangSmith will just
197+
// ignore the permitAbsentRunTree arg.
198+
(
199+
getCurrentRunTree as (
200+
permitAbsentRunTree: boolean
201+
) => ReturnType<typeof getCurrentRunTree> | undefined
202+
)(true)
203+
);
196204
} catch {
197205
return undefined;
198206
}

0 commit comments

Comments
 (0)