Skip to content

Commit 5557e59

Browse files
authored
Merge branch 'main' into codex/fix-any-signal-listener
2 parents 6da2ada + a4ef9f2 commit 5557e59

6 files changed

Lines changed: 95 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2222
with:
2323
persist-credentials: false
24-
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
24+
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
2525
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
2626
with:
2727
node-version: 24
@@ -40,7 +40,7 @@ jobs:
4040
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4141
with:
4242
persist-credentials: false
43-
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
43+
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
4444
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
4545
with:
4646
node-version: 24
@@ -69,7 +69,7 @@ jobs:
6969
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7070
with:
7171
persist-credentials: false
72-
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
72+
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
7373
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
7474
with:
7575
node-version: 24
@@ -168,7 +168,7 @@ jobs:
168168
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
169169
with:
170170
persist-credentials: false
171-
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
171+
- uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
172172
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
173173
with:
174174
node-version: 24

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252

5353
# Initializes the CodeQL tools for scanning.
5454
- name: Initialize CodeQL
55-
uses: github/codeql-action/init@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
55+
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
5656
with:
5757
languages: ${{ matrix.language }}
5858
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -70,7 +70,7 @@ jobs:
7070
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
7171
# If this step fails, then you should remove it and run the build manually (see below)
7272
- name: Autobuild
73-
uses: github/codeql-action/autobuild@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
73+
uses: github/codeql-action/autobuild@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
7474

7575
# ℹ️ Command-line programs to run using the OS shell.
7676
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -83,6 +83,6 @@ jobs:
8383
# ./location_of_script_within_repo/buildscript.sh
8484

8585
- name: Perform CodeQL Analysis
86-
uses: github/codeql-action/analyze@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
86+
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
8787
with:
8888
category: "/language:${{matrix.language}}"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
persist-credentials: false
9797

9898
- name: Setup pnpm
99-
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
99+
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
100100

101101
- name: Setup Node.js
102102
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0

.github/workflows/zizmor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
persist-credentials: false
2828
- name: Run zizmor
29-
uses: zizmorcore/zizmor-action@6fc4b006235f201fdab3722e17240ab420d580e5 # v0.6.1
29+
uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2
3030
with:
3131
advanced-security: ${{ github.event_name == 'push' && 'true' || 'false' }}
3232
min-severity: low

packages/langchain/src/CallbackHandler.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ export class CallbackHandler extends BaseCallbackHandler {
290290

291291
const modelParameters: Record<string, any> = {};
292292
const invocationParams = extraParams?.["invocation_params"];
293+
const tools = (invocationParams as any)?.tools;
294+
const toolChoice = (invocationParams as any)?.tool_choice;
293295

294296
for (const [key, value] of Object.entries({
295297
temperature: (invocationParams as any)?.temperature,
@@ -339,7 +341,16 @@ export class CallbackHandler extends BaseCallbackHandler {
339341
tags,
340342
runName,
341343
attributes: {
342-
input: messages,
344+
input:
345+
tools !== undefined || toolChoice !== undefined
346+
? {
347+
messages,
348+
...(tools !== undefined ? { tools } : {}),
349+
...(toolChoice !== undefined
350+
? { tool_choice: toolChoice }
351+
: {}),
352+
}
353+
: messages,
343354
model: extractedModelName,
344355
modelParameters: modelParameters,
345356
prompt: registeredPrompt,

tests/integration/langchain.integration.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,78 @@ describe("LangChain callback handler integration tests", () => {
6464
"The result is: 100",
6565
);
6666
});
67+
68+
it("should include tools and tool choice in generation input", async () => {
69+
const handler = new CallbackHandler();
70+
const runId = "generation-with-tools";
71+
const tools = [
72+
{
73+
type: "function",
74+
function: {
75+
name: "validate_customer",
76+
description: "Validates a customer",
77+
parameters: {
78+
type: "object",
79+
properties: { id: { type: "string" } },
80+
},
81+
},
82+
},
83+
];
84+
85+
await handler.handleGenerationStart(
86+
{ id: ["ChatOpenAI"] },
87+
[{ role: "user", content: "hi" }],
88+
runId,
89+
undefined,
90+
{
91+
invocation_params: {
92+
model: "gpt-4.1-mini",
93+
temperature: 0.2,
94+
tools,
95+
tool_choice: "auto",
96+
},
97+
},
98+
);
99+
await handler.handleLLMEnd({ generations: [[{ text: "ok" }]] }, runId);
100+
101+
await waitForSpanExport(testEnv.mockExporter, 1);
102+
103+
assertions.expectSpanAttributeContains(
104+
"ChatOpenAI",
105+
LangfuseOtelSpanAttributes.OBSERVATION_INPUT,
106+
'"name":"validate_customer"',
107+
);
108+
assertions.expectSpanAttributeContains(
109+
"ChatOpenAI",
110+
LangfuseOtelSpanAttributes.OBSERVATION_INPUT,
111+
'"tool_choice":"auto"',
112+
);
113+
assertions.expectSpanAttributeContains(
114+
"ChatOpenAI",
115+
LangfuseOtelSpanAttributes.OBSERVATION_MODEL_PARAMETERS,
116+
'"temperature":0.2',
117+
);
118+
});
119+
120+
it("should preserve message-array input without tool configuration", async () => {
121+
const handler = new CallbackHandler();
122+
const runId = "generation-without-tools";
123+
124+
await handler.handleGenerationStart(
125+
{ id: ["ChatOpenAI"] },
126+
[{ role: "user", content: "hi" }],
127+
runId,
128+
undefined,
129+
{ invocation_params: { model: "gpt-4.1-mini" } },
130+
);
131+
await handler.handleLLMEnd({ generations: [[{ text: "ok" }]] }, runId);
132+
133+
await waitForSpanExport(testEnv.mockExporter, 1);
134+
135+
assertions.expectSpanAttribute(
136+
"ChatOpenAI",
137+
LangfuseOtelSpanAttributes.OBSERVATION_INPUT,
138+
'[{"role":"user","content":"hi"}]',
139+
);
140+
});
67141
});

0 commit comments

Comments
 (0)