TOOL WIKI · AGENT SDKS

LangChain

Connects model integrations, tools, and an agent abstraction for application development.

Download example files Code + setup + checks in a ZIP
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

WHAT IT ISAgent framework
WHERE IT FITSAgent SDKs
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
taskinvokedecisiontool callresultstatemeasureApplicationTask + identityLangChainAgent frameworkModel providerConfigured API modelTool serviceAuthorization + executionState storageRun and thread progressEvaluationOutcome + evidence
  1. Authenticate the request and define the goal before calling the framework.

  2. Starting with a standard agent interface and integrating application services. Inspect the execution and message history before adding more abstractions.

  3. The application supplies provider credentials, model selection, and budgets.

  4. Validate each operation and return authoritative observations.

  5. Choose the checkpoint or session store and its retention policy deliberately.

    Result or stopping point
  6. Check completion, cost, latency, and tool behavior against fixtures.

    Result or stopping point
LangChain

Starting with a standard agent interface and integrating application services. Inspect the execution and message history before adding more abstractions.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

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.
Shell
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

Python · 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

Shell
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.
Read the LangChain walkthrough

Keep exploring

Workflow, single agent, or multiple agents?Build an explicit agent loop with LangGraph

Explore the same layer

OpenAI Agents SDKClaude Agent SDKGoogle ADKLangGraph

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.