Skip to content

Conversation

@mdrxy
Copy link
Member

@mdrxy mdrxy commented Dec 10, 2025

Widen bind_tools to accept TypedDict via Mapping so that users may import and use Anthropic's built-in tool types:

import subprocess

from anthropic.types.beta import BetaToolBash20250124Param
from langchain.tools import tool

tool_spec = BetaToolBash20250124Param(
    name="bash",
    type="bash_20250124",
    strict=True,
)

@tool(extras={"provider_tool_definition": tool_spec})
def bash(*, command: str, restart: bool = False, **kw):
    """Execute a bash command."""
    if restart:
        return "Bash session restarted"
    try:
        result = subprocess.run(
            command,
            shell=True,
            capture_output=True,
            text=True,
            timeout=30,
        )
        return result.stdout + result.stderr
    except Exception as e:
        return f"Error: {e}"

# Bind bash tool to your model

mdrxy and others added 28 commits November 26, 2025 23:03
# Conflicts:
#	libs/partners/anthropic/langchain_anthropic/chat_models.py
#	libs/partners/anthropic/tests/unit_tests/test_chat_models.py
#	libs/partners/anthropic/uv.lock
# Conflicts:
#	libs/partners/anthropic/tests/integration_tests/test_chat_models.py
#	libs/partners/anthropic/tests/unit_tests/test_chat_models.py
# Conflicts:
#	libs/partners/anthropic/langchain_anthropic/chat_models.py
#	libs/partners/anthropic/tests/integration_tests/test_chat_models.py
Ensures requisite data are propagated correctly in invoke and stream:
- `caller` on `tool_use` blocks
- `container` in response_metadata

We also introduce an initialization param `reuse_last_container` that
will automatically pass-in container IDs from the most recent model
response.

---------

Co-authored-by: Mason Daugherty <[email protected]>
Co-authored-by: Mason Daugherty <[email protected]>
@mdrxy mdrxy requested a review from ccurme as a code owner December 10, 2025 06:31
@github-actions github-actions bot added the integration PR made that is related to a provider partner package integration label Dec 10, 2025
@mdrxy mdrxy changed the title feat(anthropic): tool factories, executable callbacks feat(anthropic): executable tools Dec 11, 2025
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 11, 2025
@mdrxy mdrxy changed the title feat(anthropic): executable tools feat(anthropic): add AnthropicBuiltinTool support Dec 12, 2025
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 12, 2025
@mdrxy mdrxy changed the title feat(anthropic): add AnthropicBuiltinTool support feat(anthropic): accept TypedDict for built-in tool types Dec 12, 2025
@github-actions github-actions bot added feature For PRs that implement a new feature; NOT A FEATURE REQUEST and removed feature For PRs that implement a new feature; NOT A FEATURE REQUEST labels Dec 12, 2025
@mdrxy mdrxy merged commit 2cff369 into master Dec 12, 2025
63 of 65 checks passed
@mdrxy mdrxy deleted the mdrxy/thropic-tool-types branch December 12, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

anthropic `langchain-anthropic` package issues & PRs feature For PRs that implement a new feature; NOT A FEATURE REQUEST integration PR made that is related to a provider partner package integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants