Open
Conversation
Raw Python callables passed to bind_tools() lack the schema metadata required to generate a valid OpenAI tools[].function spec, causing a 400 "Missing required parameter: 'tools[0].function'" error. Wrapping each callable with StructuredTool.from_function(name=config_key) also ensures the model response carries the config key as the tool name, fixing a separate bug where function.__name__ was being tracked instead of the LaunchDarkly config key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_to_openai_name converted hyphens to underscores based on an assumed
restriction that doesn't exist — the OpenAI API allows hyphens in tool
and function names (^[a-zA-Z0-9_-]{1,64}$). Removing it simplifies the
tool name lookup and agent naming.
Also adds model=model.name to the Agent constructor so each node runs
with its configured model rather than the SDK default.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously, tool tracking relied on wrapping custom FunctionTools, which meant native hosted tools (WebSearchTool, FileSearchTool, etc.) were never tracked since they run server-side with no local callback. Instead, parse result.new_items after the run completes. Each ToolCallItem carries the originating agent (node attribution) and raw tool call data, covering both custom and native tools without requiring local execution. Also adds openai-agents as an optional dependency and dev dependency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
langgraph is required to use LangGraphAgentGraphRunner but was not listed as a dependency. Adding it as an optional extra (graph) and dev dependency, consistent with how openai-agents is handled in the openai provider. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove FileSearchTool, CodeInterpreterTool, ImageGenerationTool from the native tool map; they require mandatory constructor args not available from the LD config and were already broken before. - Move StructuredTool import inside the tools loop so it is only attempted when tools are present, fixing a test that mocks langchain_core without langchain_core.tools. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main refactored _build_native_tool_map into openai_helper.py as NATIVE_OPENAI_TOOLS and improved get_ai_usage_from_response to handle RunResult objects. Merged with our changes by: - Keeping only WebSearchTool in NATIVE_OPENAI_TOOLS (others require mandatory constructor args not available from config) - Importing NATIVE_OPENAI_TOOLS, get_ai_usage_from_response, and get_tool_calls_from_run_items from the helper - Retaining model=model.name in the Agent constructor - Retaining result-based tool call tracking (no wrapper tracking) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
||
| # --- tools --- | ||
| agent_tools: List[Tool] = [] | ||
| agent_tools: List[Any] = [] |
Contributor
There was a problem hiding this comment.
Would it be too annoying to type this to each tool? Basically Union[FunctionTool, WebSearchTool, ComputerUseTool....] They don't export a "base" tool unfortunately
Comment on lines
+100
to
+103
| log.warning( | ||
| f"Tool '{name}' is defined in the AI config but was not found in " | ||
| "the tool registry; skipping." | ||
| ) |
Contributor
There was a problem hiding this comment.
Nit: not addressing your PR here but should we re-think the strict linting rule for line length? Seems like we run into it more than just with my long prompts
andrewklatzke
approved these changes
Apr 1, 2026
Contributor
andrewklatzke
left a comment
There was a problem hiding this comment.
Paid particular attention to the OpenAI path as I know langgraph is still being tweaked, left just one question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Medium Risk
Changes tool binding/normalization and metrics attribution in the LangChain/LangGraph and OpenAI Agents runners, which can affect tool execution and telemetry emitted during agent/graph runs. Risk is mitigated by added integration-style tracking tests, but behavior depends on external SDKs (
langgraph,openai-agents, OpenAI tools API).Overview
Improves agent/graph tool wiring and telemetry across providers. LangChain removes structured-tool wrapping in favor of passing registry callables directly (
build_tools), drops tool binding fromcreate_langchain_model, and centralizes “last message output” extraction viaextract_last_message_contentused by both agent and LangGraph runners.OpenAI provider updates tool support and tracking for
openai-agents. Tool handling is refactored to accept either plain callables or native agentsToolinstances (registry_value_to_agent_tool), sanitize agent names for SDK compatibility, and attribute$ld:ai:tool_callevents by parsingRunResult.new_items. OpenAI model creation now normalizes LD tool definitions to the Chat Completions API shape (including native tool type mapping).Packaging/tests: Adds optional dependency groups for
langgraphandopenai-agents, and introduces new integration-style tracking tests for LangGraph and OpenAI Agents to validate emitted LD events (tokens, latency, path, handoffs, tool calls).Written by Cursor Bugbot for commit 51f3ba6. This will update automatically on new commits. Configure here.