langchain-ai
langchain
BlogDocsChangelog

fix: Add bind_tools support to RunnableSequence for structured output chains

#32175Closed
Comparing
20ns:master
(
d24af2b
) with
master
(
10996a2
)
CodSpeed Performance Gauge
+1%
Untouched
13

Benchmarks

Passed

test_import_time[HumanMessage]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+4%
215.7 ms208.3 ms
test_import_time[CallbackManager]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+3%
427.7 ms416.7 ms
test_import_time[Runnable]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+3%
234.9 ms228.9 ms
test_import_time[tool]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+2%
477.4 ms468.5 ms
test_import_time[InMemoryRateLimiter]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
165.4 ms163.9 ms
test_import_time[LangChainTracer]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
410.9 ms407.2 ms
test_import_time[RunnableLambda]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
230.3 ms228.4 ms
test_import_time[InMemoryVectorStore]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
240.3 ms238.7 ms
test_import_time[Document]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
+1%
207.1 ms205.8 ms
test_import_time[BaseChatModel]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
0%
490.8 ms489.6 ms
test_import_time[PydanticOutputParser]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
0%
365 ms364.8 ms
test_import_time[ChatPromptTemplate]
libs/core/tests/benchmarks/test_imports.py
CodSpeed Performance Gauge
0%
412.1 ms413.1 ms
test_async_callbacks_in_sync
libs/core/tests/benchmarks/test_async_callbacks.py
CodSpeed Performance Gauge
0%
24.2 ms24.3 ms

Commits

Click on a commit to change the comparison range
Base
master
10996a2
+0.73%
fix: Add bind_tools support to RunnableSequence for structured output chains This resolves issue #28848 where calling bind_tools() on a RunnableSequence created by with_structured_output() would fail with AttributeError. The fix enables the combination of structured output and tool binding, which is essential for modern AI applications that need both: - Structured JSON output formatting - External function calling capabilities **Changes:** - Added bind_tools() method to RunnableSequence class - Method intelligently detects structured output patterns - Delegates tool binding to the underlying ChatModel - Preserves existing sequence structure and behavior - Added comprehensive unit tests **Technical Details:** - Detects 2-step sequences (Model < /dev/null | Parser) from with_structured_output() - Binds tools to the first step if it supports bind_tools() - Returns new RunnableSequence with updated model + same parser - Falls back gracefully with helpful error messages **Impact:** This enables previously impossible workflows like ChatGPT-style apps that need both structured UI responses and tool calling capabilities. Fixes #28848 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
941344c
4 months ago
by 20ns
-4.45%
style: Fix linting issues in RunnableSequence.bind_tools method - Remove quoted type annotations - Fix line length violations - Remove trailing whitespace - Use double quotes consistently - Improve error message formatting for better readability The S110 warnings about try-except-pass are intentional - we want silent fallback behavior before raising the final helpful error.
e6a4c4c
4 months ago
by 20ns
+3.69%
fix: Resolve all linting and type checking issues - Replace broad Exception catching with specific exceptions (AttributeError, TypeError, ValueError) - Add proper type annotations to test functions and variables - Add type: ignore comments for dynamic method assignment in tests - Fix line length violations and formatting issues - Ensure all MyPy checks pass All lint checks now pass successfully. The S110 warnings are resolved by using more specific exception handling instead of bare try-except-pass.
d24af2b
4 months ago
by 20ns
© 2025 CodSpeed Technology
Home Terms Privacy Docs