Skip to content

feat(cli): add model profile max input tokens - #1520

Closed
Arthur Drozdov (arthur-drozdov) wants to merge 7 commits into
langchain-ai:mainfrom
arthur-drozdov:feat/cli-max-input-tokens
Closed

feat(cli): add model profile max input tokens#1520
Arthur Drozdov (arthur-drozdov) wants to merge 7 commits into
langchain-ai:mainfrom
arthur-drozdov:feat/cli-max-input-tokens

Conversation

@arthur-drozdov

@arthur-drozdov Arthur Drozdov (arthur-drozdov) commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Description

This PR allows users to set a max_input_tokens property inside their ~/.deepagents/config.toml that acts as an explicit context limit for models (like OpenAI-compatible ones) that don't auto-report their profile sizes.

The system dynamically instantiates string-declared models via langchain.chat_models.init_chat_model, allowing the context limit to be explicitly bound to the model profile upon initialization. This properly enables fraction-based triggering inside the internal CLI SummarizationMiddleware everywhere the deep agent operates, instead of defaulting to 170k.

Related issue: #444

Changes

  • Updated create_cli_agent to use init_chat_model for string models, passing the explicit profile kwarg if model_context_limit is set.
  • Fixed documentation comments to clarify summarization applicability.
  • Unit tests updated to verify correct init_chat_model patching and profile injection logic.

@github-actions github-actions Bot added cli Related to `deepagents-cli` external User is not a member of the `langchain-ai` GitHub organization feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Feb 26, 2026
@arthur-drozdov
Arthur Drozdov (arthur-drozdov) marked this pull request as draft February 26, 2026 17:53
@github-actions github-actions Bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Feb 26, 2026
@github-actions github-actions Bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Feb 26, 2026
@arthur-drozdov
Arthur Drozdov (arthur-drozdov) marked this pull request as ready for review February 26, 2026 19:11
@github-actions github-actions Bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Feb 26, 2026
@mdrxy

Copy link
Copy Markdown
Member

Covered in #1605, #1603 - thanks for the initiative!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to `deepagents-cli` external User is not a member of the `langchain-ai` GitHub organization feature New feature/enhancement or request for one

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants