langgraph.json file to work with shared dependencies.
Repository Structure
For complete working examples, see:LangGraph.json configuration
Place the langgraph.json file in your agent’s directory (not in the monorepo root). Ensure the file follows the required structure:- Detecting relative paths that start with
".". - Adding parent directories to the Docker build context as needed.
- Supporting both real packages (with
pyproject.toml/setup.py) and simple Python modules.
- Shared workspace dependencies are resolved automatically by your package manager.
- Your
package.jsonshould reference shared packages using workspace syntax.
package.json in the agent directory:
Building the application
Runlanggraph build:
- Automatically detects relative dependency paths.
- Copies shared packages into the Docker build context.
- Installs all dependencies in the correct order.
- No special flags or commands required.
- Uses the directory you called
langgraph buildfrom (the monorepo root in this case) as the build context. - Automatically detects your package manager (yarn, npm, pnpm, bun)
- Runs the appropriate install command.
- If you have one or both of a custom build/install command it will run from the directory you called
langgraph buildfrom. - Otherwise, it will run from the directory where the
langgraph.jsonfile is located.
- If you have one or both of a custom build/install command it will run from the directory you called
- Optionally runs a custom build command from the directory where the
langgraph.jsonfile is located (only if you pass the--build-commandflag).
Tips and Best Practices
-
Keep agent configs in agent directories: Place
langgraph.jsonfiles in the specific agent directories, not at the monorepo root. This allows you to support multiple agents in the same monorepo, without having to deploy them all in the same LangGraph platform deployment. -
Use relative paths for Python: For Python monorepos, use relative paths like
"../../shared-package"in thedependenciesarray. - Leverage workspace features for JS: For JavaScript/TypeScript, use your package manager’s workspace features to manage dependencies between packages.
- Test locally first: Always test your build locally before deploying to ensure all dependencies are correctly resolved.
-
Environment variables: Keep environment files (
.env) in your agent directories for environment-specific configuration.