Commit 842bd34
fix: Replace fan-out with handoff routing and fix OpenAI message ordering
- Add _coalesce_tool_messages_for_openai to fix parallel fan-out causing
OpenAI 400 errors when sibling branch tool_calls have no ToolMessages
- Add LDMetricsCallbackHandler for per-node token/tool/latency tracking
- Add build_structured_tools with async callable support via inspect
- Replace fan-out static edges with LLM-driven handoff tools (Command(goto=))
- Switch WorkflowState.messages to add_messages reducer
- Add parallel_tool_calls=False when handoff tools present
- Remove _coalesce_tool_messages_for_openai (no longer needed with handoffs)
- Demote diagnostic logs to debug; exclude handoff tools from LD tracking
- Consolidate token extraction to use get_ai_usage_from_response
- Fix TestBuildTools to import build_structured_tools; cover async callables
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 53fd95e commit 842bd34
7 files changed
Lines changed: 1600 additions & 92 deletions
File tree
- packages/ai-providers/server-ai-langchain
- src/ldai_langchain
- tests
Lines changed: 30 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | | - | |
160 | | - | |
161 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| |||
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| |||
234 | 239 | | |
235 | 240 | | |
236 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
237 | 256 | | |
238 | 257 | | |
239 | 258 | | |
| |||
0 commit comments