Skip to content

Commit f9fe772

Browse files
authored
Update langchain to 1.x (#364)
1 parent 9f8a25f commit f9fe772

File tree

8 files changed

+2422
-2799
lines changed

8 files changed

+2422
-2799
lines changed

.github/workflows/badge-spider.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
script: |
2525
const badgeAggregation = require('./scripts/badge_aggregation.js');
2626
const dependencies = [
27-
{ workflow: 'examples-spider.yml', label: 'spider', variants: ['stable', 'legacy'] },
27+
{ workflow: 'examples-spider.yml', label: 'spider', variants: ['stable'] },
2828
];
2929
await badgeAggregation({ github, context, core, dependencies });

.github/workflows/examples-spider.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ jobs:
3333
strategy:
3434
matrix:
3535
include:
36-
- python-version: '3.10'
37-
setup-script: 'legacy'
36+
# legacy is omitted because langchain doesn't work with legacy vllm versions
3837
- python-version: '3.12'
3938
setup-script: 'stable'
4039
- python-version: '3.13'
@@ -58,13 +57,13 @@ jobs:
5857
- name: Sync dependencies (latest)
5958
run: |
6059
uv sync --frozen --no-default-groups --extra verl \
61-
--group dev --group experiment --group agents --group torch-gpu-stable
60+
--group dev --group experiment --group agents --group langchain --group torch-gpu-stable
6261
if: matrix.setup-script == 'latest'
63-
- name: Sync dependencies (stable & legacy)
62+
- name: Sync dependencies (stable)
6463
run: |
6564
uv sync --frozen --no-default-groups --extra verl \
66-
--group dev --group experiment --group agents --group torch-gpu-${{ matrix.setup-script }}
67-
if: matrix.setup-script != 'latest'
65+
--group dev --group experiment --group agents --group langchain --group torch-gpu-${{ matrix.setup-script }}
66+
if: matrix.setup-script == 'stable'
6867
- name: Freeze dependencies
6968
run: |
7069
set -ex

.github/workflows/tests-full.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ jobs:
5656
run: uv lock --upgrade
5757
if: matrix.setup-script == 'latest'
5858
- name: Sync dependencies (latest)
59-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group torch-gpu-stable
59+
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group torch-gpu-stable
6060
if: matrix.setup-script == 'latest'
61-
- name: Sync dependencies (stable & legacy)
62-
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group torch-gpu-${{ matrix.setup-script }}
63-
if: matrix.setup-script != 'latest'
61+
- name: Sync dependencies (stable)
62+
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group torch-gpu-${{ matrix.setup-script }}
63+
if: matrix.setup-script == 'stable'
64+
# Don't install langchain for legacy dependency because it has conflicts with torch.
65+
- name: Sync dependencies (legacy)
66+
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group torch-gpu-legacy
67+
if: matrix.setup-script == 'legacy'
6468
- name: Freeze dependencies
6569
run: |
6670
set -ex
@@ -178,11 +182,15 @@ jobs:
178182
run: uv lock --upgrade
179183
if: matrix.setup-script == 'latest'
180184
- name: Sync dependencies (latest)
181-
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group torch-gpu-stable
185+
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group langchain --group torch-gpu-stable
182186
if: matrix.setup-script == 'latest'
183-
- name: Sync dependencies (stable & legacy)
184-
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group torch-gpu-${{ matrix.setup-script }}
185-
if: matrix.setup-script != 'latest'
187+
- name: Sync dependencies (stable)
188+
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group langchain --group torch-gpu-${{ matrix.setup-script }}
189+
if: matrix.setup-script == 'stable'
190+
# Don't install langchain for legacy dependency because it has conflicts with torch.
191+
- name: Sync dependencies (legacy)
192+
run: uv sync --frozen --no-default-groups --extra apo --extra mongo --group dev --group agents --group torch-gpu-legacy
193+
if: matrix.setup-script == 'legacy'
186194
- name: Freeze dependencies
187195
run: |
188196
set -ex

.github/workflows/tests.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
--group trl \
4545
--group tinker \
4646
--group agents \
47+
--group langchain \
4748
--no-default-groups
4849
if: matrix.setup == 'slow'
4950
# This pre-commit skips JavaScript on purpose.
@@ -139,10 +140,10 @@ jobs:
139140
run: uv lock --upgrade
140141
if: matrix.setup-script == 'latest'
141142
- name: Sync dependencies (latest)
142-
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group core-stable
143+
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group langchain --group core-stable
143144
if: matrix.setup-script == 'latest'
144145
- name: Sync dependencies (stable & legacy)
145-
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group core-${{ matrix.setup-script }}
146+
run: uv sync --frozen --no-default-groups --extra apo --group dev --group agents --group langchain --group core-${{ matrix.setup-script }}
146147
if: matrix.setup-script != 'latest'
147148
- name: Freeze dependencies
148149
run: |

pyproject.toml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ anthropic = [
183183
"anthropic",
184184
]
185185
langchain = [
186-
"langgraph<1.0",
187-
"langchain[openai]<1.0",
188-
"langchain-community",
189-
"langchain-text-splitters<1.0",
186+
"langgraph>=1.0.0",
187+
"langchain[openai]>=1.0.0",
188+
"langchain-community>=0.4.0",
189+
"langchain-text-splitters>=1.0.0",
190190
]
191191
sql = [
192192
"sqlparse",
@@ -206,10 +206,11 @@ swebench = [
206206
]
207207

208208
# Summarize into large installable groups.
209+
# Note: langchain is excluded from agents to avoid conflicts with torch-legacy.
210+
# Use --group langchain explicitly when needed.
209211
agents = [
210212
{include-group = "autogen"},
211213
{include-group = "openai-agents"},
212-
{include-group = "langchain"},
213214
{include-group = "sql"},
214215
{include-group = "anthropic"},
215216
{include-group = "crewai"},
@@ -231,6 +232,12 @@ conflicts = [
231232
{ group = "torch-stable" },
232233
{ group = "torch-legacy" },
233234
],
235+
# langchain >= 1.0 requires openai >= 1.109.1 (via langchain-openai),
236+
# but torch-legacy uses vllm==0.9.2 which requires openai<=1.90.0
237+
[
238+
{ group = "langchain" },
239+
{ group = "torch-legacy" },
240+
],
234241
]
235242
environments = [
236243
"sys_platform == 'linux'",
@@ -250,6 +257,9 @@ override-dependencies = [
250257
# Conflicts between litellm and fastmcp
251258
"websockets>=15.0.1",
252259
"rich>=13.9.4",
260+
# verl's numpy<2.0.0 constraint is related to Docker images, not code incompatibility
261+
# Lock to 2.3.0 because numba relies on numpy 2.2
262+
"numpy>=2.0.0,<2.3.0",
253263
]
254264

255265
[tool.uv.sources]

tests/assets/prompt_caches.jsonl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828
{"request": {"messages": [{"content": "Return 1.0 if the answer is 8, else 0.0.", "role": "system"}, {"role": "user", "content": "8"}], "model": "gpt-4.1-mini", "response_format": {"type": "json_schema", "json_schema": {"name": "final_output", "strict": true, "schema": {"properties": {"response": {"title": "Response", "type": "number"}}, "required": ["response"], "title": "OutputType", "type": "object", "additionalProperties": false}}}}, "response": {"choices": [{"content_filter_results": {"hate": {"filtered": false, "severity": "safe"}, "protected_material_code": {"filtered": false, "detected": false}, "protected_material_text": {"filtered": false, "detected": false}, "self_harm": {"filtered": false, "severity": "safe"}, "sexual": {"filtered": false, "severity": "safe"}, "violence": {"filtered": false, "severity": "safe"}}, "finish_reason": "stop", "index": 0, "logprobs": null, "message": {"annotations": [], "content": "{\"response\":1.0}", "refusal": null, "role": "assistant"}}], "created": 1763565701, "id": "chatcmpl-CdeI1ifu2oOt06oTodWPpSpNFAqIN", "model": "gpt-4.1-mini-2025-04-14", "object": "chat.completion", "prompt_filter_results": [{"prompt_index": 0, "content_filter_results": {"hate": {"filtered": false, "severity": "safe"}, "jailbreak": {"filtered": false, "detected": false}, "self_harm": {"filtered": false, "severity": "safe"}, "sexual": {"filtered": false, "severity": "safe"}, "violence": {"filtered": false, "severity": "safe"}}}], "system_fingerprint": "fp_3dcd5944f5", "usage": {"completion_tokens": 8, "completion_tokens_details": {"accepted_prediction_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 0, "rejected_prediction_tokens": 0}, "prompt_tokens": 65, "prompt_tokens_details": {"audio_tokens": 0, "cached_tokens": 0}, "total_tokens": 73}}}
2929
{"request": {"messages": [{"content": "If the question is about math, handoff to MathAgent. Otherwise, handoff to HistoryAgent.", "role": "system"}, {"role": "user", "content": "Who was the first president of the US?"}], "model": "gpt-4.1-mini", "tools": [{"type": "function", "function": {"name": "transfer_to_mathagent", "description": "Handoff to the MathAgent agent to handle the request. ", "parameters": {"additionalProperties": false, "type": "object", "properties": {}, "required": []}}}, {"type": "function", "function": {"name": "transfer_to_historyagent", "description": "Handoff to the HistoryAgent agent to handle the request. ", "parameters": {"additionalProperties": false, "type": "object", "properties": {}, "required": []}}}]}, "response": {"choices": [{"content_filter_results": {}, "finish_reason": "tool_calls", "index": 0, "logprobs": null, "message": {"annotations": [], "content": null, "refusal": null, "role": "assistant", "tool_calls": [{"function": {"arguments": "{}", "name": "transfer_to_historyagent"}, "id": "call_tXXmrsNYcFlKrG9hMo2Yk0E3", "type": "function"}]}}], "created": 1763565706, "id": "chatcmpl-CdeI6hxlaAwzbn7Sx4ZTXZs0Hx3E5", "model": "gpt-4.1-mini-2025-04-14", "object": "chat.completion", "prompt_filter_results": [{"prompt_index": 0, "content_filter_results": {"hate": {"filtered": false, "severity": "safe"}, "jailbreak": {"filtered": false, "detected": false}, "self_harm": {"filtered": false, "severity": "safe"}, "sexual": {"filtered": false, "severity": "safe"}, "violence": {"filtered": false, "severity": "safe"}}}], "system_fingerprint": "fp_3dcd5944f5", "usage": {"completion_tokens": 13, "completion_tokens_details": {"accepted_prediction_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 0, "rejected_prediction_tokens": 0}, "prompt_tokens": 97, "prompt_tokens_details": {"audio_tokens": 0, "cached_tokens": 0}, "total_tokens": 110}}}
3030
{"request": {"messages": [{"content": "Answer history questions.", "role": "system"}, {"role": "assistant", "content": "For context, here is the conversation so far between the user and the previous agent:\n<CONVERSATION HISTORY>\n1. user: Who was the first president of the US?\n2. function_call: {\"arguments\": \"{}\", \"call_id\": \"call_tXXmrsNYcFlKrG9hMo2Yk0E3\", \"name\": \"transfer_to_historyagent\", \"id\": \"__fake_id__\"}\n3. function_call_output: {\"call_id\": \"call_tXXmrsNYcFlKrG9hMo2Yk0E3\", \"output\": \"{\\\"assistant\\\": \\\"HistoryAgent\\\"}\"}\n</CONVERSATION HISTORY>"}, {"role": "assistant", "tool_calls": [{"id": "call_tXXmrsNYcFlKrG9hMo2Yk0E3", "type": "function", "function": {"name": "transfer_to_historyagent", "arguments": "{}"}}]}, {"role": "tool", "tool_call_id": "call_tXXmrsNYcFlKrG9hMo2Yk0E3", "content": "{\"assistant\": \"HistoryAgent\"}"}], "model": "gpt-4.1-mini"}, "response": {"choices": [{"content_filter_results": {"hate": {"filtered": false, "severity": "safe"}, "protected_material_text": {"filtered": false, "detected": false}, "self_harm": {"filtered": false, "severity": "safe"}, "sexual": {"filtered": false, "severity": "safe"}, "violence": {"filtered": false, "severity": "safe"}}, "finish_reason": "stop", "index": 0, "logprobs": null, "message": {"annotations": [], "content": "The first president of the United States was George Washington. He served as president from 1789 to 1797. If you have more questions about U.S. history or any other historical events, feel free to ask!", "refusal": null, "role": "assistant"}}], "created": 1763565707, "id": "chatcmpl-CdeI78NuMQmjmeuwLhx3I0Qqcem99", "model": "gpt-4.1-mini-2025-04-14", "object": "chat.completion", "prompt_filter_results": [{"prompt_index": 0, "content_filter_results": {}}], "system_fingerprint": "fp_3dcd5944f5", "usage": {"completion_tokens": 46, "completion_tokens_details": {"accepted_prediction_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 0, "rejected_prediction_tokens": 0}, "prompt_tokens": 179, "prompt_tokens_details": {"audio_tokens": 0, "cached_tokens": 0}, "total_tokens": 225}}}
31+
{"request": {"messages": [{"role": "system", "content": "You are a helpful assistant. Use the multiply tool to answer math questions."}, {"role": "user", "content": "what is 42 * 12"}], "model": "gpt-4.1-mini", "tools": [{"type": "function", "function": {"name": "multiply", "description": "A simple calculator tool that multiplies two integers.", "parameters": {"type": "object", "properties": {"a_and_b": {"type": "string"}}, "required": ["a_and_b"]}}}]}, "response": {"id": "chatcmpl-test1", "model": "gpt-4.1-mini", "object": "chat.completion", "created": 1750758616, "choices": [{"index": 0, "message": {"role": "assistant", "content": null, "tool_calls": [{"id": "call_abc123", "type": "function", "function": {"name": "multiply", "arguments": "{\"a_and_b\": \"42 and 12\"}"}}]}, "finish_reason": "tool_calls"}], "usage": {"prompt_tokens": 100, "completion_tokens": 20, "total_tokens": 120}}}
32+
{"request": {"messages": [{"role": "system", "content": "You are a helpful assistant. Use the multiply tool to answer math questions."}, {"role": "user", "content": "what is 42 * 12"}, {"role": "assistant", "content": null, "tool_calls": [{"id": "call_abc123", "type": "function", "function": {"name": "multiply", "arguments": "{\"a_and_b\": \"42 and 12\"}"}}]}, {"role": "tool", "content": "504", "tool_call_id": "call_abc123"}], "model": "gpt-4.1-mini", "tools": [{"type": "function", "function": {"name": "multiply", "description": "A simple calculator tool that multiplies two integers.", "parameters": {"type": "object", "properties": {"a_and_b": {"type": "string"}}, "required": ["a_and_b"]}}}]}, "response": {"id": "chatcmpl-test2", "model": "gpt-4.1-mini", "object": "chat.completion", "created": 1750758617, "choices": [{"index": 0, "message": {"role": "assistant", "content": "The result of 42 * 12 is 504."}, "finish_reason": "stop"}], "usage": {"prompt_tokens": 150, "completion_tokens": 15, "total_tokens": 165}}}

0 commit comments

Comments
 (0)