Agent application framework
How to use
LangChain.
Building agents with standardized model interfaces, typed tools, structured output, middleware, persistence, and human approval controls.
LangChain is a open-source framework for building model- and tool-using agents. Building agents with standardized model interfaces, typed tools, structured output, middleware, persistence, and human approval controls. This guide covers the whole path in one place: official access, a first session that produces something reviewable, the checks that make output trustworthy, and the permissions worth limiting before you connect real work.
AI should make the work easier to inspect. If the workflow removes the source, the owner, or the review step, redesign the workflow.
Access & setup
Find, install, and sign in to LangChain
Get into the official LangChain experience with the right account and a setup you understand.
- 01
Start at https://www.langchain.com/ and confirm the domain before entering account or payment information.
- 02
Availability: LangChain is installed as Python or JavaScript packages and used in an application development environment rather than as a required desktop app.
- 03
A supported Python or JavaScript runtime, chosen model-provider credentials or local model access, and separately configured services for any tools or persistence.
- 04
Sign in with the account you intend to keep using, then review plan, data, notification, and permission settings.
- 05
Run one low-risk test task before connecting sensitive files, repositories, or workspace data.
- Use official download pages.
- Review permissions during setup.
- Keep installers and applications updated.
First session
Your first useful LangChain session
Learn the interaction loop using a small task with a clear outcome.
- 01
Define a bounded task, output schema, stop condition, and the minimum tools the model may call.
- 02
Install current packages and keep provider and service credentials in environment secrets.
- 03
Create an agent with narrow typed tools, an explicit system prompt, and structured output validation.
- 04
Trace and test normal, adversarial, tool-error, and approval cases before adding broader capabilities.
- State the outcome before the background.
- Provide the real source material.
- Review the result before expanding the task.
Quality control
Check the quality of LangChain output
Establish that an autonomous run did the right thing, not merely that it finished.
- 01
Define what the run should achieve and what it must never touch before granting it a single tool.
- 02
Read the full execution trace: which tools were called, with what arguments, and in what order.
- 03
Verify the side effects directly in the target system rather than trusting the agent's own report of success.
- 04
Confirm failures surfaced as failures — a silent retry loop or a swallowed error is more dangerous than a crash.
- 05
Re-run the same task and compare: an agent that behaves differently across identical runs is not yet production-ready.
- Verify side effects in the system of record, not in the agent's summary.
- Require human approval for any irreversible or outward-facing action.
- Log every tool call so a run can be reconstructed afterwards.
Privacy & permissions
Use LangChain safely
Bound what an autonomous system can reach before you let it run unattended.
- 01
Enumerate every tool, credential, and system the agent can reach, and remove the ones it does not need.
- 02
Require explicit human approval for irreversible actions: sending, publishing, paying, deleting, or deploying.
- 03
Run against non-production data until behaviour is predictable across repeated runs.
- 04
Set hard limits on spend, iterations, and runtime so a failure loop cannot run unbounded.
- 05
Treat anything the agent reads from the web or a document as data, never as instructions it may follow.
- Framework abstractions do not make model choices or tools safe. Validate every tool boundary, limit iterations and cost, protect credentials, isolate user state, trace behavior, and require approval for consequential actions.
- Follow your organisation's approved-use policy.
- Never treat fluent output as authorization to act.
Core workflows
Step-by-step ways to use LangChain for the work it does best.
Each workflow below has its own outcome, steps and review checkpoints.
Create a small agent whose tools, state, stop conditions, and machine-readable output are explicit.
↓ 02 WorkflowAdd approval gates and production controls to a LangChain agentPause consequential tool calls for review while preserving resumable state and observable decisions.
↓Workflow 01
Build a bounded tool-calling agent with LangChain
Create a small agent whose tools, state, stop conditions, and machine-readable output are explicit.
Outcome: Implement a useful agent loop without giving the model broader access or ambiguity than the task requires.
- 01
Write the task contract, accepted inputs, output schema, success criteria, iteration limit, and actions that require approval.
- 02
Choose a supported model and define the minimum tools with narrow typed arguments, clear descriptions, validated returns, and timeouts.
- 03
Create the agent with an explicit system prompt and structured response schema, keeping credentials and authorization inside tool code.
- 04
Run normal, ambiguous, adversarial, tool-error, repeated-call, and malformed-output cases while recording the complete execution trace.
- 05
Add middleware for retries, limits, redaction, and human review, then pin dependencies and version the test set before release.
What good use looks like
- Expose the fewest possible tools.
- Validate every tool boundary.
- Bound agent iterations and cost.
Workflow 02
Add approval gates and production controls to a LangChain agent
Pause consequential tool calls for review while preserving resumable state and observable decisions.
Outcome: Prevent a model from autonomously performing irreversible or sensitive actions in production.
- 01
Classify each tool as read-only, reversible, sensitive, or irreversible and define allowed approve, edit, and reject decisions.
- 02
Configure human-in-the-loop middleware for consequential tools and use a persistent production checkpointer with isolated thread IDs.
- 03
Present reviewers with the exact tool, arguments, affected resource, model rationale, and policy context without exposing secrets.
- 04
Test approval, edited arguments, rejection, expiration, duplicate resume, process restart, and unauthorized reviewer paths.
- 05
Trace decisions, tool results, latency, errors, and cost with retention controls, then alert on bypasses and repeated failures.
What good use looks like
- Gate effects, not just prompts.
- Use durable state for pauses.
- Make reviewer identity auditable.
Official references
Check the current product documentation.
Features, plan limits, availability, and data controls change. These official pages are the starting points used for this guide.