feat(code): configurable Auto classifier review timeout - #5302
Merged
Mason Daugherty (mdrxy) merged 5 commits intoAug 4, 2026
Conversation
The Auto approval classifier's per-batch deadline was a hardcoded 20s module constant. Users whose classifier model is slow saw gated tool calls denied as `classifier_unavailable` with no way to raise the budget. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Mason Daugherty (mdrxy)
marked this pull request as ready for review
August 4, 2026 14:47
…t resolution The `config`/`config get` reporting path resolved `models.auto_classifier_timeout` through the generic scalar resolver, so an out-of-range env value (e.g. `DEEPAGENTS_CODE_AUTO_CLASSIFIER_TIMEOUT=0`) was reported as the effective value even though the runtime discards it and falls through to `config.toml` or the default. Route the option through a new `resolve_auto_classifier_timeout_with_source` so the displayed value and source match what the middleware actually enforces.
Address review findings on the configurable Auto classifier review deadline. Guard the fall-through branch in `resolve_auto_classifier_timeout_with_source`: its termination depends on the env name reconstructed from the `source` label actually being the key `resolve_scalar` read. If it is not, the `os.environ.pop` is a no-op and re-resolving sees the same rejected value again, recursing until `RecursionError` — on the startup path, where `make_graph` would surface it only as an opaque launch failure. Reject a non-positive or non-finite budget in `AutoModeHITLMiddleware.__init__`, alongside the existing trusted-tool invariants. User config is bounded by the resolver, but a programmatic zero expires `asyncio.timeout` immediately and silently turns Auto into blanket denials. Correct the documentation to match the implementation: - `THREAT_MODEL.md` revision-log row was dated seven days in the future. - T14 said the deadline is tunable through "the same trusted surfaces" as the classifier model, which include a CLI flag and `/auto model`; the timeout has neither. It also said the resolver "bounds" the value, which reads as clamping when out-of-range values are in fact discarded in favor of the next layer. - `AUTO_CLASSIFIER_TIMEOUT` advised raising the deadline for a slow classifier without noting that the separate model-construction budget is fixed at 30s, so a user whose first batch fails on a cold provider import sees no change. State the accepted range there and in the option summary (the string `config` and `--help` render), and that the value is resolved once per launch. - Auto degrades into repeated denials *and approval prompts*, not blanket denials: `_CONSECUTIVE_UNAVAILABLE_FALLBACK` escalates to human approval. - `_is_valid_auto_classifier_timeout` rejects a bare `int`; the floor rationale contradicted its own inclusive bound. Close the matching test gaps: the rejection warning is a user's only signal that their setting was discarded and was unasserted; the `config.toml` rejection branch was unreachable under the suite; the two fall-through mechanisms (malformed vs out-of-range) were not distinguished; the project `.env` preview denial passed equally well if the file was never read; and the wiring test asserted a constant that is also the middleware's own parameter default, so it held even with the keyword removed from `create_cli_agent`.
Mason Daugherty (mdrxy)
deleted the
mdrxy/code/auto-classifier-timeout-config
branch
August 4, 2026 17:29
Mason Daugherty (mdrxy)
added a commit
to langchain-ai/docs
that referenced
this pull request
Aug 4, 2026
…5295) Fixes DOC-1486 Rebases on top of #5271 (selectable classifier model docs) per review feedback. **Set base to `docs/auto-classifier-model` once #5271 merges, or retarget this PR to that branch.** ## Summary - `config-file.mdx` — new **Auto classifier timeout** section after "Startup approval mode", with config.toml and env var tabs. Recommends switching to a faster classifier model (via `[models].auto_classifier`) before raising the deadline. - `configuration.mdx` — new `DEEPAGENTS_CODE_AUTO_CLASSIFIER_TIMEOUT` env var entry in the reference table, with a note to prefer changing the classifier model first. ## Links - Linear: https://linear.app/langchain/issue/DOC-1486/document-configurable-auto-classifier-review-timeout-for-deep-agents - Slack: https://langchain.slack.com/archives/C09G1T60QV9/p1785859372092309 - Source PR: langchain-ai/deepagents#5302 - Depends on: #5271 ## Verification - `make lint_prose` run; one pre-existing `LangChain.DashesSpaces` error in `config-file.mdx` (the `ModelProfile` line) exists on the base branch and is not introduced by this PR. ## Reviewers Requested review from: @mdrxy, @npentrel --------- Co-authored-by: Docs Writer Bot <brace@langchain.dev> Co-authored-by: Mason Daugherty <mason@langchain.dev> Co-authored-by: Naomi Pentrel <5212232+npentrel@users.noreply.github.com>
Johannes du Plessis (johannes117)
pushed a commit
that referenced
this pull request
Aug 4, 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`. Publish reads the merged CHANGELOG via `release.yml`, not this PR description — keep them aligned anyway so the PR stays an accurate historical record for reviewers and anyone returning later._ --- ## [0.1.52](deepagents-code==0.1.51...deepagents-code==0.1.52) (2026-08-04) ### Features - Hooks v2 is now generally available, with support for loading hooks from installed plugins. ([#5307](#5307), [#5198](#5198)) - Auto approval classifier configuration now supports selecting the classifier model and setting a review timeout. ([#5205](#5205), [#5302](#5302)) - HITL rejection reasons are now framed for the model, and the approval menu makes reject-with-feedback easier to discover. ([#5259](#5259), [#5260](#5260)) - Added a tri-state `DEEPAGENTS_CODE_ONBOARDING` environment variable. ([#5301](#5301)) - The `/model` footer Ctrl+N hint now follows the current display mode. ([#5247](#5247)) - The price catalog now refreshes hourly in the background. ([#5264](#5264)) - Updated recommendations to include DeepSeek V4 Flash 0731. ([#5244](#5244)) ### Bug Fixes - Fixed several Hooks v2 lifecycle issues: session-end teardown is now bounded, hooks refresh after cwd switches, malformed hook resumes are handled, hook stops surface without agent errors, and unused `SessionEndCause` members were removed. ([#5248](#5248), [#5249](#5249), [#5233](#5233), [#5276](#5276), [#5240](#5240)) - `PreCompact` now fires before auto-compaction. ([#5277](#5277)) _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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The deadline the Auto approval classifier gets to review one batch of gated actions is now configurable via
DEEPAGENTS_CODE_AUTO_CLASSIFIER_TIMEOUTor[models].auto_classifier_timeout, instead of being fixed at 20 seconds.Auto mode reviews gated tool calls with an LLM authorization classifier. That review had a hardcoded 20-second budget: a batch that missed it was denied as
classifier_unavailable, the tool call never ran, and repeated misses escalated to manual approval. Users on a slow or heavily loaded classifier model hit this regularly and had no way to raise it —AutoModeHITLMiddlewarealready accepted aclassifier_timeout_secondskeyword, but nothing in the app ever passed one, so only tests could change it.The option follows the same shape as the existing
runtime.recursion_limitknob rather than inventing a new pattern: a typed default and explicit floor/ceiling constants in the config manifest, and aresolve_auto_classifier_timeoutresolver with env →config.toml→ default precedence.Made by Open SWE