Skip to content

Conversation

@sydney-runkle
Copy link
Collaborator

@sydney-runkle sydney-runkle commented Nov 20, 2025

overview

The main purpose of this is to respect tool signatures that request injected args (like ToolRuntime) even when the explicitly specified args_schema does not.

Ex in the following example, we should still inject runtime despite its absence in ArgsSchema

class ArgsSchema(BaseModel):
    some_arg: int = Field(...)

@tool(args_schema=ArgsSchema)
def my_tool(some_arg: int, runtime: ToolRuntime): ...

This is accompanied by langchain-ai/langchain#34051 which has tests that pass w/ this change. This tests injection w/ create_agent (more end to end than tests added in langchain-ai/langchain#33999.

This unblocks the injection of ToolRuntime into MCP tools which is exciting bc that exposes tool call id and state, which we previously were unable to do.

other benefits

  • Cleaner code structure w/ more helpful docs about injected args.
  • Nice perf boost, we're no longer inspecting the annotations of a tool's schema 3 different times to detect store, state, and runtime injections.

additional notes

  1. I could see a world where we want more of this logic to reside on the tools themselves, but tools don't now about LG specific injection types (like ToolRuntime, hence having this logic here for now).
  2. We could separately add validation for the case where something is specified in args_schema and not in the function signature (probably at the tool level though).

@vercel
Copy link

vercel bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langgraph-docs-preview Ignored Ignored Preview Nov 20, 2025 3:49pm

]


def test__get_state_args() -> None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested elsewhere

@sydney-runkle
Copy link
Collaborator Author

wow double approval! I'm honored :)

@sydney-runkle sydney-runkle merged commit 2164b7d into main Nov 20, 2025
67 checks passed
@sydney-runkle sydney-runkle deleted the sr/refactoring-tool-node-mwahah branch November 20, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants