Skip to content

feat(config): add per-request token budget - #909

Open
ousamabenyounes wants to merge 1 commit into
usestrix:mainfrom
ousamabenyounes:feat/issue-231-token-budget
Open

feat(config): add per-request token budget#909
ousamabenyounes wants to merge 1 commit into
usestrix:mainfrom
ousamabenyounes:feat/issue-231-token-budget

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Fixes #231.

Summary

  • Adds STRIX_LLM_MAX_TOKENS as an optional positive integer setting.
  • Applies that value to every root/child agent request through the shared make_model_settings path.
  • Documents the new environment variable in advanced configuration.

Test verification (RED -> GREEN)

RED on origin/main with only the helper regression test added:

$ uv run pytest tests/test_inputs.py::test_make_model_settings_sets_configured_token_budget -q
E   TypeError: make_model_settings() got an unexpected keyword argument 'max_tokens'
1 failed

GREEN after the fix:

$ uv run pytest tests/test_inputs.py::test_make_model_settings_sets_configured_token_budget tests/test_runner_root_prompt.py::test_llm_max_tokens_flows_into_model_settings tests/test_config_loader.py::test_llm_max_tokens_env_alias -q
3 passed

Fix-reverted proof:

$ git apply -R /tmp/strix-issue-231-fix.patch && uv run pytest tests/test_inputs.py::test_make_model_settings_sets_configured_token_budget -q
E   TypeError: make_model_settings() got an unexpected keyword argument 'max_tokens'
1 failed

Validation

  • uv run pytest tests/test_inputs.py tests/test_config_loader.py tests/test_runner_root_prompt.py tests/test_runner_rate_limit.py tests/test_models.py -q -> 117 passed, 2 warnings
  • uv run ruff check strix/config/settings.py strix/core/inputs.py strix/core/runner.py tests/test_inputs.py tests/test_config_loader.py tests/test_runner_root_prompt.py tests/test_runner_rate_limit.py -> pass
  • uv run ruff format --check strix/config/settings.py strix/core/inputs.py strix/core/runner.py tests/test_inputs.py tests/test_config_loader.py tests/test_runner_root_prompt.py tests/test_runner_rate_limit.py -> pass
  • uv run mypy strix/config/settings.py strix/core/inputs.py strix/core/runner.py tests/test_inputs.py tests/test_config_loader.py tests/test_runner_root_prompt.py tests/test_runner_rate_limit.py -> pass
  • uv run bandit -q -c pyproject.toml strix/config/settings.py strix/core/inputs.py strix/core/runner.py -> pass

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds an optional positive per-request LLM output-token limit.

  • Defines and documents STRIX_LLM_MAX_TOKENS.
  • Propagates the configured value through shared model settings used by root and child agents.
  • Adds configuration, model-settings, and runner-flow regression coverage.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The validated positive setting is resolved through the existing generic configuration path and forwarded into the single model configuration shared by root, newly spawned child, and resumed child agent requests.

Important Files Changed

Filename Overview
strix/config/settings.py Adds a positive optional max_tokens LLM setting with the expected environment alias.
strix/core/inputs.py Threads the optional token limit into the SDK's shared ModelSettings.
strix/core/runner.py Passes the resolved token limit into the shared run configuration used by root and child agents.
docs/advanced/configuration.mdx Documents the new environment variable and its unset behavior.
tests/test_config_loader.py Covers parsing the new environment alias.
tests/test_inputs.py Verifies that the helper places the configured budget in model settings.
tests/test_runner_root_prompt.py Verifies that the runner forwards the resolved budget to the model-settings helper.
tests/test_runner_rate_limit.py Updates the settings fixture to reflect the expanded LLM settings shape.

Reviews (1): Last reviewed commit: "feat(config): add per-request token budg..." | Re-trigger Greptile

@ousamabenyounes
ousamabenyounes force-pushed the feat/issue-231-token-budget branch from 01e59f0 to 31f88bd Compare July 27, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support configurable token budget per LLM request

1 participant