Skip to content

Commit 120d6b8

Browse files
authored
fix(core): Fix interop case where callbacks are manually passed to a runnable, t… (#8696)
1 parent fe79533 commit 120d6b8

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

docs/core_docs/docusaurus.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ const config = {
146146
respectPrefersColorScheme: true,
147147
},
148148
announcementBar: {
149-
content: 'Our new LangChain Academy Course Deep Research with LangGraph is now live! <a href="https://academy.langchain.com/courses/deep-research-with-langgraph/?utm_medium=internal&utm_source=docs&utm_campaign=q3-2025_deep-research-course_co" target="_blank">Enroll for free</a>.',
149+
content:
150+
'Our new LangChain Academy Course Deep Research with LangGraph is now live! <a href="https://academy.langchain.com/courses/deep-research-with-langgraph/?utm_medium=internal&utm_source=docs&utm_campaign=q3-2025_deep-research-course_co" target="_blank">Enroll for free</a>.',
150151
backgroundColor: "#d0c9fe",
151152
},
152153
prism: {

langchain-core/src/tracers/tests/langsmith_interop.int.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { traceable } from "langsmith/traceable";
44
import { RunnableLambda } from "../../runnables/base.js";
55
import { BaseMessage, HumanMessage } from "../../messages/index.js";
66
import { awaitAllCallbacks } from "../../singletons/callbacks.js";
7+
import { LangChainTracer } from "../tracer_langchain.js";
78

89
test("traceables double nested within runnables with batching", async () => {
910
const aiGreet = traceable(
@@ -27,3 +28,28 @@ test("traceables double nested within runnables with batching", async () => {
2728

2829
await awaitAllCallbacks();
2930
});
31+
32+
test("runnable nested within a traceable with manual tracer passed", async () => {
33+
const aiGreet = traceable(
34+
async (msg: BaseMessage) => {
35+
const child = RunnableLambda.from(async () => {
36+
return [new HumanMessage({ content: "From child!" })];
37+
}).withConfig({ runName: "child" });
38+
return child.invoke([msg]);
39+
},
40+
{ name: "aiGreet", tracingEnabled: true }
41+
);
42+
43+
const parent = RunnableLambda.from(async () => {
44+
return aiGreet(new HumanMessage({ content: "Hello!" }));
45+
}).withConfig({ runName: "parent" });
46+
47+
await parent.invoke(
48+
{},
49+
{
50+
callbacks: [new LangChainTracer()],
51+
}
52+
);
53+
54+
await awaitAllCallbacks();
55+
});

langchain-core/src/tracers/tracer_langchain.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class LangChainTracer
9191
}
9292

9393
updateFromRunTree(runTree: RunTree) {
94+
this.runTreeMap.set(runTree.id, runTree);
9495
let rootRun: RunTree = runTree;
9596
const visited = new Set<string>();
9697
while (rootRun.parent_run) {

0 commit comments

Comments
 (0)