Skip to content

Conversation

@sydney-runkle
Copy link
Collaborator

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

  • use override instead of directly patching things on ModelRequest
  • rely on ToolNode for execution of tools related to said middleware, using wrap_model_call to inject the relevant claude tool specs + allowing tool node to forward them along to corresponding langchain tool implementations
  • making the same change for the native shell tool middleware
  • allowing shell tool middleware to specify a name for the shell tool (negative diff then for claude bash middleware)

long term I think the solution might be to attach metadata to a tool to map the provider spec to a langchain implementation, which we could also take some lessons from on the MCP front.

@github-actions github-actions bot added integration Related to a provider partner package integration anthropic fix and removed fix labels Nov 14, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 14, 2025

CodSpeed Performance Report

Merging #33960 will not alter performance

Comparing sr/final-fixes (37e51d1) with master (83c078f)

Summary

✅ 3 untouched
⏩ 31 skipped1

Footnotes

  1. 31 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@mdrxy mdrxy changed the title fix: execute bash + file tools via tool node fix(anthropic): execute bash + file tools via tool node Nov 14, 2025
@github-actions github-actions bot added fix and removed fix labels Nov 14, 2025
Base automatically changed from sr/verifying-remaining to master November 14, 2025 14:13
@github-actions github-actions bot added langchain Related to the package `langchain` fix and removed fix labels Nov 14, 2025
* properly register shell tool w/ tool node
* inherit this improvement in claude shell tool middleware as well
* allow for configuration of tool name (which allows for claude impl to
use `bash` as required by the anthropic api)
@github-actions github-actions bot added fix and removed fix labels Nov 14, 2025
execution_policy: BaseExecutionPolicy | None = None,
redaction_rules: tuple[RedactionRule, ...] | list[RedactionRule] | None = None,
tool_description: str | None = None,
tool_name: str = SHELL_TOOL_NAME,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: inline the tool name perhaps? it's only used in one place

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have it as an arg here so that we can override it in the anthropic implementation

Copy link
Collaborator

Choose a reason for hiding this comment

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

i meant to not use SHELL_TOOL_NAME and instead tool_name = "shell" , a global variable for one use case feels a bit odd

AgentState,
ModelRequest,
ModelResponse,
_ModelRequestOverrides,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to make this public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good question, I think no for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel comfortable importing this in a partner lib

@sydney-runkle sydney-runkle merged commit 1bc8802 into master Nov 14, 2025
88 checks passed
@sydney-runkle sydney-runkle deleted the sr/final-fixes branch November 14, 2025 18:17
sydney-runkle added a commit that referenced this pull request Nov 14, 2025
* use `override` instead of directly patching things on `ModelRequest`
* rely on `ToolNode` for execution of tools related to said middleware,
using `wrap_model_call` to inject the relevant claude tool specs +
allowing tool node to forward them along to corresponding langchain tool
implementations
* making the same change for the native shell tool middleware
* allowing shell tool middleware to specify a name for the shell tool
(negative diff then for claude bash middleware)


long term I think the solution might be to attach metadata to a tool to
map the provider spec to a langchain implementation, which we could also
take some lessons from on the MCP front.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

anthropic fix integration Related to a provider partner package integration langchain Related to the package `langchain`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants