A current LangChain search tool should return an evidence record the agent can inspect, rather than an unlabelled string that hides its source. Use the current create_agent interface, keep credentials outside the tool output and distinguish a tested tool contract from a model’s decision to invoke it.
A small tool-contract fixture
import json
from langchain.tools import tool
@tool
def evidence_search(query: str) -> str:
"""Return a local source record for the fixture query."""
return json.dumps({"query": query, "url": "https://example.org/docs",
"checked_at": "2026-10-10",
"text": "The fixture supports version 2."})
record = json.loads(evidence_search.invoke({"query": "fixture"}))
assert record["url"] == "https://example.org/docs"
This tool returns a synthetic record. The revision tested tool invocation and create_agent construction with installed LangChain 1.4.4 and a mock model. It did not test a real model selecting the tool or the quality of a generated answer.
Replace the fixture with an evidence-producing implementation
A production create_agent call needs a supported configured model and credentials. Refer to current LangChain documentation for that model binding instead of copying an obsolete initialize_agent or LLMChain pattern.
- Use the provider’s documented request and validate its success envelope.
- Select permitted source URLs and read the material needed to support the answer.
- Return source identity, observation time, extraction status and useful text.
- Set timeouts and budgets outside model-written arguments.
- Keep unavailable or unsupported evidence visible to the calling agent.
Test the downstream boundary
Check that a malformed response does not become a valid evidence record, that duplicate source identities remain identifiable, and that insufficient evidence can produce an unresolved answer. The parent agent guide covers the whole architecture; this page covers the search-tool binding.
Reference documentation: docs.langchain.com — /oss/python/langchain/agents; docs.langchain.com — /oss/python/langchain/tools; www.searchcans.com — /google-search-api.