test_tool_decorator_description() — langchain Function Reference
Architecture documentation for the test_tool_decorator_description() function in test_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 06ee692b_30ec_9d71_b5f6_20247b372270["test_tool_decorator_description()"] 8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"] 06ee692b_30ec_9d71_b5f6_20247b372270 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555 2c2c109d_134c_f484_653a_c7d3d1685d09["foo()"] 06ee692b_30ec_9d71_b5f6_20247b372270 -->|calls| 2c2c109d_134c_f484_653a_c7d3d1685d09 style 06ee692b_30ec_9d71_b5f6_20247b372270 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/test_tools.py lines 2716–2803
def test_tool_decorator_description() -> None:
# test basic tool
@tool
def foo(x: int) -> str:
"""Foo."""
return "hi"
assert foo.description == "Foo."
assert (
cast("BaseModel", foo.tool_call_schema).model_json_schema()["description"]
== "Foo."
)
# test basic tool with description
@tool(description="description")
def foo_description(x: int) -> str:
"""Foo."""
return "hi"
assert foo_description.description == "description"
assert (
cast("BaseModel", foo_description.tool_call_schema).model_json_schema()[
"description"
]
== "description"
)
# test tool with args schema
class ArgsSchema(BaseModel):
"""Bar."""
x: int
@tool(args_schema=ArgsSchema)
def foo_args_schema(x: int) -> str:
return "hi"
assert foo_args_schema.description == "Bar."
assert (
cast("BaseModel", foo_args_schema.tool_call_schema).model_json_schema()[
"description"
]
== "Bar."
)
@tool(description="description", args_schema=ArgsSchema)
def foo_args_schema_description(x: int) -> str:
return "hi"
assert foo_args_schema_description.description == "description"
assert (
cast(
"BaseModel", foo_args_schema_description.tool_call_schema
).model_json_schema()["description"]
== "description"
)
args_json_schema = {
"description": "JSON Schema.",
"properties": {
"x": {"description": "my field", "title": "X", "type": "string"}
},
"required": ["x"],
"title": "my_tool",
"type": "object",
}
@tool(args_schema=args_json_schema)
def foo_args_jsons_schema(x: int) -> str:
return "hi"
@tool(description="description", args_schema=args_json_schema)
def foo_args_jsons_schema_with_description(x: int) -> str:
return "hi"
assert foo_args_jsons_schema.description == "JSON Schema."
assert (
cast("dict[str, Any]", foo_args_jsons_schema.tool_call_schema)["description"]
== "JSON Schema."
)
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does test_tool_decorator_description() do?
test_tool_decorator_description() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_tool_decorator_description() defined?
test_tool_decorator_description() is defined in libs/core/tests/unit_tests/test_tools.py at line 2716.
What does test_tool_decorator_description() call?
test_tool_decorator_description() calls 1 function(s): foo.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free