# How to set recursion\_limit for create\_agent (v1)?

**URL:** https://forum.langchain.com/t/how-to-set-recursion-limit-for-create-agent-v1/1905
**Category:** LangChain Academy
**Tags:** python-help
**Created:** [October 22, 2025, 10:48pm UTC](https://forum.langchain.com/t/how-to-set-recursion-limit-for-create-agent-v1/1905 "2025-10-22T22:48:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![UK59](https://avatars.discourse-cdn.com/v4/letter/u/edb3f5/32.png) [@UK59](https://forum.langchain.com/u/UK59)
#### Post date: [October 22, 2025, 10:48pm UTC](https://forum.langchain.com/t/how-to-set-recursion-limit-for-create-agent-v1/1905/1 "2025-10-22T22:48:53Z")

</div>

Hey everyone,

I’m running into this error when using the new `create_agent` function (LangChain v1):

```auto
Recursion limit of 25 reached without hitting a stop condition. You can increase the limit by setting the recursion_limit config key.

```

I’d like to increase this limit, but I can’t find any clear documentation on _where or how_ to set the `recursion_limit` config key for `create_agent`.

Does anyone know the correct syntax or location for setting this (e.g., inside the config dict or as a parameter to `create_agent`)?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![Jameskanyiri](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/jameskanyiri/32/993_2.png) [@Jameskanyiri](https://forum.langchain.com/u/Jameskanyiri)
#### Post date: [October 23, 2025, 5:04am UTC](https://forum.langchain.com/t/how-to-set-recursion-limit-for-create-agent-v1/1905/2 "2025-10-23T05:04:31Z")

</div>

Hey @UK59 you can try do the following

```python
agent = create_agent(

    model=model,

tools=tools,

prompt=AGENT_PROMPT.format(date=get_today_str()),

state_schema=DeepAgentState,

).with_config({"recursion_limit": 50})

```

---

<div class="post-metadata">

### Author: ![pawel-twardziak](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/pawel-twardziak/32/960_2.png) [@pawel-twardziak](https://forum.langchain.com/u/pawel-twardziak)
#### Post date: [October 23, 2025, 11:04am UTC](https://forum.langchain.com/t/how-to-set-recursion-limit-for-create-agent-v1/1905/3 "2025-10-23T11:04:55Z")

</div>

hi @UK59 and @Jameskanyiri

@Jameskanyiri 's answer should solve your issue. Here is the doc for it [Runnables](https://reference.langchain.com/python/langchain_core/runnables/#langchain_core.runnables.base.Runnable.with_config)

`with_config` sets the default values for `Runnable`.

You might want to change it at runtime. If so, check those docs:

- [Graph API overview - Docs by LangChain](https://docs.langchain.com/oss/python/langgraph/graph-api#recursion-limit)
- [Use the graph API - Docs by LangChain](https://docs.langchain.com/oss/python/langgraph/use-graph-api#impose-a-recursion-limit)
