Skip to content

feat(code): raise agent recursion limit to 2000 and make it configurable - #4994

Merged
Mason Daugherty (mdrxy) merged 6 commits into
mainfrom
mdrxy/code/recursion-limit-override
Jul 23, 2026
Merged

feat(code): raise agent recursion limit to 2000 and make it configurable#4994
Mason Daugherty (mdrxy) merged 6 commits into
mainfrom
mdrxy/code/recursion-limit-override

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jul 23, 2026

Copy link
Copy Markdown
Member

The dcode main agent's LangGraph recursion_limit was hardcoded to 1000, which long-running sessions were hitting (GRAPH_RECURSION_LIMIT). This raises the default to 2000 and makes it user-tunable via a --recursion-limit CLI flag, a DEEPAGENTS_CODE_RECURSION_LIMIT env var, or [runtime].recursion_limit in config.toml, resolved with precedence CLI > env > config.toml > default.


The default now lives once in config_manifest as RECURSION_LIMIT_DEFAULT, consumed by both the config.config runnable-config fallback and the new runtime.recursion_limit manifest option, so config/config get surface it automatically. create_cli_agent resolves the effective limit at build time via resolve_recursion_limit, which validates the value against an inclusive floor (25, the LangGraph default ceiling) and ceiling (100_000) and logs a warning and falls back to the default for out-of-range or malformed values, so a bad override can never break runs or request unbounded traversal. The CLI value threads through ServerConfig (mirroring rubric_max_iterations) to the server-side agent build.

goal_rubric recursion limits are unrelated and untouched.

Test plan
  • runtime.recursion_limit resolution: env wins, config.toml fallback, default, and out-of-range/malformed fallback (incl. floor/ceiling bounds).
  • ServerConfig round-trip + __post_init__ validation for recursion_limit.
  • --recursion-limit argparse parsing (positive int; rejects 0/negatives) and help-screen drift.
  • Regression: config.config["recursion_limit"] == 2000 == RECURSION_LIMIT_DEFAULT.
  • make format, make lint (ruff + ty + commands-catalog) all pass.

Made by Open SWE

References

Long-running dcode sessions were hitting GRAPH_RECURSION_LIMIT with the
overly defensive 1000 default. Raise it to 2000, single-source the constant
in config_manifest, and add a `runtime.recursion_limit` override resolved with
CLI > env > config.toml > default precedence.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC labels Jul 23, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review July 23, 2026 13:09

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 2 potential issues.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/config_manifest.py
Comment thread libs/code/deepagents_code/main.py
Mason Daugherty (mdrxy) and others added 2 commits July 23, 2026 11:30
Invalid env values now fall through to TOML/default instead of masking them, and --recursion-limit is threaded through ACP mode.
@mdrxy
Mason Daugherty (mdrxy) merged commit 94962a5 into main Jul 23, 2026
54 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/recursion-limit-override branch July 23, 2026 15:43
Mason Daugherty (mdrxy) added a commit to langchain-ai/docs that referenced this pull request Jul 23, 2026
Fixes DOC-1422

## Summary

- Adds a new `[runtime].recursion_limit` section to `config-file.mdx`
documenting the `config.toml` key, env var
(`DEEPAGENTS_CODE_RECURSION_LIMIT`), and `--recursion-limit` CLI flag
for configuring the agent's LangGraph recursion limit.
- Adds `--recursion-limit` to the command-line options table in
`cli-reference.mdx`.
- Adds `DEEPAGENTS_CODE_RECURSION_LIMIT` to the environment variable
reference in `configuration.mdx`.

Default is `2000` (raised from `1000`). Valid range: 25–100,000.
Precedence: CLI > env > config.toml > default. Introduced in
[langchain-ai/deepagents#4994](langchain-ai/deepagents#4994).

## Links

- Linear:
https://linear.app/langchain/issue/DOC-1422/document-configurable-recursion-limit-for-dcode-recursion-limit-env
- Slack:
https://langchain.slack.com/archives/C09G1T60QV9/p1784821272598629
- Source PR: langchain-ai/deepagents#4994

## Verification

Not run; docs-only copy change.

## Reviewers

Requested review from: @npentrel, @lnhsingh

---------

Co-authored-by: Docs Writer <brace@langchain.dev>
Co-authored-by: Mason Daugherty <mason@langchain.dev>
Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com>
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Jul 24, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. The published GitHub release body is extracted from the
merged `CHANGELOG.md` by `release.yml`, not from this PR description._

---


##
[0.1.46](deepagents-code==0.1.45...deepagents-code==0.1.46)
(2026-07-24)

### Highlights

- Auto mode is now generally available.
[#4957](#4957)
- Added configurable Auto goal-criteria acceptance.
[#4940](#4940)
- Improved Auto behavior by authorizing actions from active goal/rubric
directives, avoiding redundant approval prompts, showing the enable
notice only on first global enable, deduplicating classifier-unavailable
transcript spam, logging underlying classifier failures, and reporting
classifier timeout budgets.
[#5017](#5017)
[#4993](#4993)
[#5012](#5012)
[#5013](#5013)
[#5011](#5011)
[#5025](#5025)
- Added Hooks v2 capability snapshots and session transcripts, and
hardened Hooks v2 command execution.
[#4916](#4916)
[#4918](#4918)
[#4917](#4917)
- Raised the agent recursion limit to 2000 and made it configurable.
[#4994](#4994)

### Improvements and fixes

- Let the rubric grader inspect working-directory files, show rubric
grader defaults, and improved `/rubric` help and empty-state messaging.
[#4835](#4835)
[#4966](#4966)
[#5015](#5015)
- Unified goal activation signaling.
[#4980](#4980)
- Made Version, Model, and CWD copyable in the Debug Console.
[#4975](#4975)
- Improved `config get` output when a key is missing.
[#4976](#4976)
- Aborted YOLO launch on `Ctrl+C`/`Ctrl+D` and made the YOLO warning
friendlier for new users.
[#4953](#4953)
[#4950](#4950)
- Updated LangSmith handling: secret redaction is disabled by default,
`/trace` now flags empty env overrides that shadow the LangSmith key,
and the default US endpoint is no longer treated as a custom target.
[#4970](#4970)
[#4996](#4996)
[#5022](#5022)
- Injected OpenAI `prompt_cache_key` for any OpenAI-provider endpoint.
[#4995](#4995)
- Improved tool and schema presentation: finished calls stay on the live
tool-group line, first-party tool schemas now include field
descriptions, and `web_search`/`fetch_url` tool descriptions were
trimmed. [#4927](#4927)
[#5019](#5019)
[#5016](#5016)
- Omitted `plugins/` and `conversation_history/` from the `/agent`
picker. [#4991](#4991)
- Made selector modal backdrop dimming consistent.
[#4990](#4990)
- Restored the `"Server log preserved at:"` notice on exit.
[#4999](#4999)
- Used the SDK pin as the effective editable version.
[#4949](#4949)

_End release notes preview._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
…ble (langchain-ai#4994)

The `dcode` main agent's LangGraph `recursion_limit` was hardcoded to
`1000`, which long-running sessions were hitting
(`GRAPH_RECURSION_LIMIT`). This raises the default to `2000` and makes
it user-tunable via a `--recursion-limit` CLI flag, a
`DEEPAGENTS_CODE_RECURSION_LIMIT` env var, or
`[runtime].recursion_limit` in `config.toml`, resolved with precedence
CLI > env > `config.toml` > default.

---

The default now lives once in `config_manifest` as
`RECURSION_LIMIT_DEFAULT`, consumed by both the `config.config`
runnable-config fallback and the new `runtime.recursion_limit` manifest
option, so `config`/`config get` surface it automatically.
`create_cli_agent` resolves the effective limit at build time via
`resolve_recursion_limit`, which validates the value against an
inclusive floor (`25`, the LangGraph default ceiling) and ceiling
(`100_000`) and logs a warning and falls back to the default for
out-of-range or malformed values, so a bad override can never break runs
or request unbounded traversal. The CLI value threads through
`ServerConfig` (mirroring `rubric_max_iterations`) to the server-side
agent build.

`goal_rubric` recursion limits are unrelated and untouched.

<details>
<summary>Test plan</summary>

- `runtime.recursion_limit` resolution: env wins, `config.toml`
fallback, default, and out-of-range/malformed fallback (incl.
floor/ceiling bounds).
- `ServerConfig` round-trip + `__post_init__` validation for
`recursion_limit`.
- `--recursion-limit` argparse parsing (positive int; rejects
`0`/negatives) and help-screen drift.
- Regression: `config.config["recursion_limit"] == 2000 ==
RECURSION_LIMIT_DEFAULT`.
- `make format`, `make lint` (ruff + ty + commands-catalog) all pass.

</details>

Made by [Open
SWE](https://openswe.vercel.app/agents/bd7380f1-04cf-20c3-c2f7-d0e05211f2ee)

## References
- Plan:
https://openswe.vercel.app/agents/bd7380f1-04cf-20c3-c2f7-d0e05211f2ee/plan

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Marcelo5444 pushed a commit to Marcelo5444/deepagents that referenced this pull request Jul 30, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. The published GitHub release body is extracted from the
merged `CHANGELOG.md` by `release.yml`, not from this PR description._

---


##
[0.1.46](langchain-ai/deepagents@deepagents-code==0.1.45...deepagents-code==0.1.46)
(2026-07-24)

### Highlights

- Auto mode is now generally available.
[langchain-ai#4957](langchain-ai#4957)
- Added configurable Auto goal-criteria acceptance.
[langchain-ai#4940](langchain-ai#4940)
- Improved Auto behavior by authorizing actions from active goal/rubric
directives, avoiding redundant approval prompts, showing the enable
notice only on first global enable, deduplicating classifier-unavailable
transcript spam, logging underlying classifier failures, and reporting
classifier timeout budgets.
[langchain-ai#5017](langchain-ai#5017)
[langchain-ai#4993](langchain-ai#4993)
[langchain-ai#5012](langchain-ai#5012)
[langchain-ai#5013](langchain-ai#5013)
[langchain-ai#5011](langchain-ai#5011)
[langchain-ai#5025](langchain-ai#5025)
- Added Hooks v2 capability snapshots and session transcripts, and
hardened Hooks v2 command execution.
[langchain-ai#4916](langchain-ai#4916)
[langchain-ai#4918](langchain-ai#4918)
[langchain-ai#4917](langchain-ai#4917)
- Raised the agent recursion limit to 2000 and made it configurable.
[langchain-ai#4994](langchain-ai#4994)

### Improvements and fixes

- Let the rubric grader inspect working-directory files, show rubric
grader defaults, and improved `/rubric` help and empty-state messaging.
[langchain-ai#4835](langchain-ai#4835)
[langchain-ai#4966](langchain-ai#4966)
[langchain-ai#5015](langchain-ai#5015)
- Unified goal activation signaling.
[langchain-ai#4980](langchain-ai#4980)
- Made Version, Model, and CWD copyable in the Debug Console.
[langchain-ai#4975](langchain-ai#4975)
- Improved `config get` output when a key is missing.
[langchain-ai#4976](langchain-ai#4976)
- Aborted YOLO launch on `Ctrl+C`/`Ctrl+D` and made the YOLO warning
friendlier for new users.
[langchain-ai#4953](langchain-ai#4953)
[langchain-ai#4950](langchain-ai#4950)
- Updated LangSmith handling: secret redaction is disabled by default,
`/trace` now flags empty env overrides that shadow the LangSmith key,
and the default US endpoint is no longer treated as a custom target.
[langchain-ai#4970](langchain-ai#4970)
[langchain-ai#4996](langchain-ai#4996)
[langchain-ai#5022](langchain-ai#5022)
- Injected OpenAI `prompt_cache_key` for any OpenAI-provider endpoint.
[langchain-ai#4995](langchain-ai#4995)
- Improved tool and schema presentation: finished calls stay on the live
tool-group line, first-party tool schemas now include field
descriptions, and `web_search`/`fetch_url` tool descriptions were
trimmed. [langchain-ai#4927](langchain-ai#4927)
[langchain-ai#5019](langchain-ai#5019)
[langchain-ai#5016](langchain-ai#5016)
- Omitted `plugins/` and `conversation_history/` from the `/agent`
picker. [langchain-ai#4991](langchain-ai#4991)
- Made selector modal backdrop dimming consistent.
[langchain-ai#4990](langchain-ai#4990)
- Restored the `"Server log preserved at:"` notice on exit.
[langchain-ai#4999](langchain-ai#4999)
- Used the SDK pin as the effective editable version.
[langchain-ai#4949](langchain-ai#4949)

_End release notes preview._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant