Folder Layout & Setup
In-process agent structure, barrels, and key dependencies.
In-process LangGraph.js agents live inside the API repo. Use when the pipeline is small, owned by one service, and does not need a separate LangGraph Platform deploy.
Folder layout
src/agents/
├── index.ts ← barrel: newThreadId(), threadConfig()
├── chat/ ← ReAct agent (createReactAgent)
│ ├── index.ts
│ ├── prompt.ts
│ └── tools.ts
└── pipeline/ ← StateGraph (batch or structured generation)
├── graph.ts
├── nodes.ts
├── prompts.ts
├── state.ts
└── types.tsEach agent folder exposes a public barrel (index.ts). External code imports from the barrel only.
Adding a new agent:
- Create
src/agents/<name>/withindex.ts,prompt.ts,tools.ts(andgraph.ts/state.tsfor StateGraph). - Export from
src/agents/index.ts. - Wire
src/services/<name>.service.ts, controller, and routes. - Follow Delivery standards.
Key dependencies
{
"@langchain/core": "LangChain abstractions",
"@langchain/openai": "ChatOpenAI, OpenAI bindings",
"@langchain/langgraph": "StateGraph, prebuilt ReAct agent",
"@langchain/community": "Optional tools (Tavily, etc.)"
}For hosted graphs, use @langchain/langgraph-sdk instead. See Integration flow.
See also
- Agents & pipelines
- Environment variables
- Hosted LangGraph (when to move out of the API repo)