TOOL WIKI · AGENT SDKS
LangChain
Connects model integrations, tools, and an agent abstraction for application development.
Jump to a section 10 sections
EXAMPLE USE CASE
Create a standard support-agent loop
A developer needs a small, observable agent or retrieval step before connecting real business services.
- Input
- An order question, lookup function and create_agent configuration.
- Expected output
- Tool messages and a final answer reflecting the lookup result.
- Success check: The last message contains the order status from lookup_order.
- Try a failure: An unsupported answer without the required tool call should fail evaluation.
Example scope: Actual LangChain agent with one local read-only business fixture.
Official reference · LangChain
Authenticate the request and define the goal before calling the framework.
Starting with a standard agent interface and integrating application services. Inspect the execution and message history before adding more abstractions.
invokeTo 03 · Model providertool callTo 04 · Tool servicemeasureTo 06 · EvaluationThe application supplies provider credentials, model selection, and budgets.
decisionBack to 02 · LangChainValidate each operation and return authoritative observations.
resultBack to 02 · LangChainChoose the checkpoint or session store and its retention policy deliberately.
Result or stopping pointCheck completion, cost, latency, and tool behavior against fixtures.
Result or stopping point
Starting with a standard agent interface and integrating application services. Inspect the execution and message history before adding more abstractions.
When to consider it
- Starting with a standard agent interface and integrating application services.
A design decision to make
- Inspect the execution and message history before adding more abstractions.
Prerequisites and setup
- Python 3.11+ in an empty directory. A compatible model and provider credentials are required.
- Running the model-backed example can incur API charges; this website displays it without calling a provider.
- Save the code at the displayed path, then use the corresponding run command.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install langchain langchain-openai
export OPENAI_API_KEY="your-api-key"
export OPENAI_MODEL="your-enabled-model-id"Try a small integration
agent.py
import os
from langchain.agents import create_agent
def lookup_order(order_id: str) -> str:
"""Read an order status from a local demonstration fixture."""
orders = {"A104": "Packed; awaiting courier pickup"}
return orders.get(order_id, "Order not found")
agent = create_agent(
model="openai:" + os.environ["OPENAI_MODEL"],
tools=[lookup_order],
system_prompt=(
"Use lookup_order for status questions. "
"Ground your answer in its returned data."
),
)
result = agent.invoke(
{"messages": [
{"role": "user", "content": "What is the status of A104?"}
]},
config={"recursion_limit": 8},
)
print(result["messages"][-1].content)Run and check the result
python agent.py- The last message contains the order status from lookup_order.
- The missing-order test should produce a grounded not-found response.
Common failures
- Install the provider integration package as well as langchain.
- Keep the tool docstring and parameter types: the agent uses them to construct its tool interface.
Production decisions
- Replace the local fixture with a service that enforces authenticated tenant and resource permissions.
- Add timeouts, bounded retries, tracing redaction, and a regression case for each observed failure.
- Model calls consume provider API usage when you run this example; this website only displays the code.
Keep exploring
Explore the same layer
Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.