Skip to content

Commit 5bc359c

Browse files
committed
Allow langgraph's recursion_limit to be configured through env variables
1 parent cd49e57 commit 5bc359c

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ USERS_OPEN_REGISTRATION=False
2222
MAX_UPLOAD_SIZE=50_000_000
2323
# Sets the number of processes
2424
MAX_WORKERS=1
25+
# Controls LangGraph's recursion_limit configuration parameter. If empty, defaults to 25.
26+
RECURSION_LIMIT=25
2527

2628
# llm provider keys. Add only to models that you want to use
2729
OPENAI_API_KEY=

backend/app/core/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,8 @@ def _enforce_non_default_secrets(self) -> Self:
148148

149149
MAX_UPLOAD_SIZE: int = 50_000_000
150150

151+
# LangGraph config
152+
RECURSION_LIMIT: int = 25
153+
151154

152155
settings = Settings() # type: ignore

backend/app/core/graph/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ async def generator(
509509

510510
config: RunnableConfig = {
511511
"configurable": {"thread_id": thread_id},
512-
"recursion_limit": 25,
512+
"recursion_limit": settings.RECURSION_LIMIT,
513513
}
514514
# Handle interrupt logic by orriding state
515515
if interrupt and interrupt.decision == InterruptDecision.APPROVED:

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ services:
110110
- DENSE_EMBEDDING_MODEL=${DENSE_EMBEDDING_MODEL?Variable not set}
111111
- SPARSE_EMBEDDING_MODEL=${SPARSE_EMBEDDING_MODEL?Variable not set}
112112
- MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE}
113+
- RECURSION_LIMIT=${RECURSION_LIMIT}
113114
- CELERY_BROKER_URL=redis://redis:6379/0
114115
- CELERY_RESULT_BACKEND=redis://redis:6379/0
115116
build:

0 commit comments

Comments
 (0)