Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions langchain-core/src/tracers/tests/langsmith_interop.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { traceable } from "langsmith/traceable";
import { RunnableLambda } from "../../runnables/base.js";
import { BaseMessage, HumanMessage } from "../../messages/index.js";
import { awaitAllCallbacks } from "../../singletons/callbacks.js";
import { LangChainTracer } from "../tracer_langchain.js";

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

await awaitAllCallbacks();
});

test("runnable nested within a traceable with manual tracer passed", async () => {
const aiGreet = traceable(
async (msg: BaseMessage) => {
const child = RunnableLambda.from(async () => {
return [new HumanMessage({ content: "From child!" })];
}).withConfig({ runName: "child" });
return child.invoke([msg]);
},
{ name: "aiGreet", tracingEnabled: true }
);

const parent = RunnableLambda.from(async () => {
return aiGreet(new HumanMessage({ content: "Hello!" }));
}).withConfig({ runName: "parent" });

await parent.invoke(
{},
{
callbacks: [new LangChainTracer()],
}
);

await awaitAllCallbacks();
});
1 change: 1 addition & 0 deletions langchain-core/src/tracers/tracer_langchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class LangChainTracer
}

updateFromRunTree(runTree: RunTree) {
this.runTreeMap.set(runTree.id, runTree);
let rootRun: RunTree = runTree;
const visited = new Set<string>();
while (rootRun.parent_run) {
Expand Down
Loading