@langchain/openai 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -215,10 +215,17 @@ function _convertMessagesToOpenAIResponsesParams(messages, model) {
215
215
  arguments: toolCall.function.arguments,
216
216
  })));
217
217
  }
218
- if (lcMsg.additional_kwargs.tool_outputs != null) {
219
- const toolOutputs = lcMsg.additional_kwargs
220
- .tool_outputs;
221
- const computerCalls = toolOutputs?.filter((item) => item.type === "computer_call");
218
+ const toolOutputs = lcMsg.response_metadata.output?.length
219
+ ? lcMsg.response_metadata.output
220
+ : lcMsg.additional_kwargs.tool_outputs;
221
+ if (toolOutputs != null) {
222
+ const castToolOutputs = toolOutputs;
223
+ const reasoningCalls = castToolOutputs?.filter((item) => item.type === "reasoning");
224
+ const computerCalls = castToolOutputs?.filter((item) => item.type === "computer_call");
225
+ // NOTE: Reasoning outputs must be passed to the model BEFORE computer calls.
226
+ if (reasoningCalls.length > 0 && computerCalls.length > 0) {
227
+ input.push(...reasoningCalls);
228
+ }
222
229
  if (computerCalls.length > 0)
223
230
  input.push(...computerCalls);
224
231
  }
@@ -210,10 +210,17 @@ function _convertMessagesToOpenAIResponsesParams(messages, model) {
210
210
  arguments: toolCall.function.arguments,
211
211
  })));
212
212
  }
213
- if (lcMsg.additional_kwargs.tool_outputs != null) {
214
- const toolOutputs = lcMsg.additional_kwargs
215
- .tool_outputs;
216
- const computerCalls = toolOutputs?.filter((item) => item.type === "computer_call");
213
+ const toolOutputs = lcMsg.response_metadata.output?.length
214
+ ? lcMsg.response_metadata.output
215
+ : lcMsg.additional_kwargs.tool_outputs;
216
+ if (toolOutputs != null) {
217
+ const castToolOutputs = toolOutputs;
218
+ const reasoningCalls = castToolOutputs?.filter((item) => item.type === "reasoning");
219
+ const computerCalls = castToolOutputs?.filter((item) => item.type === "computer_call");
220
+ // NOTE: Reasoning outputs must be passed to the model BEFORE computer calls.
221
+ if (reasoningCalls.length > 0 && computerCalls.length > 0) {
222
+ input.push(...reasoningCalls);
223
+ }
217
224
  if (computerCalls.length > 0)
218
225
  input.push(...computerCalls);
219
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/openai",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "OpenAI integrations for LangChain.js",
5
5
  "type": "module",
6
6
  "engines": {