Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion libs/core/langchain_core/utils/_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@
merged[right_k] = merge_lists(merged[right_k], right_v)
elif merged[right_k] == right_v:
continue
elif isinstance(merged[right_k], int):
elif isinstance(merged[right_k], (int, float)):
# Preserve identification and temporal fields using last-wins strategy
# instead of summing:
# - index: identifies which tool call a chunk belongs to
# - created/timestamp: temporal values that shouldn't be accumulated
# Note: float support added to fix streaming with float values in generation_info

Check failure on line 76 in libs/core/langchain_core/utils/_merge.py

View workflow job for this annotation

GitHub Actions / lint (libs/core, 3.12) / Python 3.12

ruff (E501)

langchain_core/utils/_merge.py:76:89: E501 Line too long (97 > 88)

Check failure on line 76 in libs/core/langchain_core/utils/_merge.py

View workflow job for this annotation

GitHub Actions / lint (libs/core, 3.11) / Python 3.11

ruff (E501)

langchain_core/utils/_merge.py:76:89: E501 Line too long (97 > 88)

Check failure on line 76 in libs/core/langchain_core/utils/_merge.py

View workflow job for this annotation

GitHub Actions / lint (libs/core, 3.10) / Python 3.10

ruff (E501)

langchain_core/utils/_merge.py:76:89: E501 Line too long (97 > 88)

Check failure on line 76 in libs/core/langchain_core/utils/_merge.py

View workflow job for this annotation

GitHub Actions / lint (libs/core, 3.14) / Python 3.14

ruff (E501)

langchain_core/utils/_merge.py:76:89: E501 Line too long (97 > 88)

Check failure on line 76 in libs/core/langchain_core/utils/_merge.py

View workflow job for this annotation

GitHub Actions / lint (libs/core, 3.13) / Python 3.13

ruff (E501)

langchain_core/utils/_merge.py:76:89: E501 Line too long (97 > 88)
if right_k in {"index", "created", "timestamp"}:
merged[right_k] = right_v
else:
Expand Down
27 changes: 19 additions & 8 deletions libs/partners/openai/langchain_openai/chat_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4492,17 +4492,28 @@ def _construct_lc_result_from_responses_api(
try:
args = json.loads(output.arguments, strict=False)
error = None
except JSONDecodeError as e:
except (JSONDecodeError, TypeError) as e:
args = output.arguments
error = str(e)
if error is None:
tool_call = {
"type": "tool_call",
"name": output.name,
"args": args,
"id": output.call_id,
}
tool_calls.append(tool_call)
if not isinstance(args, dict):
error = f"Expected dict, got {type(args).__name__}"
tool_call = {
"type": "invalid_tool_call",
"name": output.name,
"args": args,
"id": output.call_id,
"error": error,
}
invalid_tool_calls.append(tool_call)
else:
tool_call = {
"type": "tool_call",
"name": output.name,
"args": args,
"id": output.call_id,
}
tool_calls.append(tool_call)
else:
tool_call = {
"type": "invalid_tool_call",
Expand Down
Loading