Skip to content

feat(config): task variables for the context window #4225

Closed

Description

@dan-petty

Problem

The baseline of the stage eval (#3566) runs with a context window of 131072 tokens for each run. It sets the window with the variable DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW. The issue #3566 names this variable, but it does not exist.

Facts, checked on 2026-11-09:

  • _TASK_VARIABLES in src/devops_cli/config/settings.py holds only provider, model, reasoning_effort and ollama_urls. docs/ENV_VARS.md lists no CONTEXT_WINDOW or MAX_TOKENS variable for a task.
  • With DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW=131072 set, load_settings().ai.for_task('stage').context_window returns 262144. The variable has no effect and raises no error.
  • The task verification has no Variable(fields=...) marker, so it has no variable at all.
  • The fields context_window and max_tokens exist on AITaskOverride, so ai.tasks.<task>.context_window works in config.yaml already. Only the environment variable is missing.

Without the variable, a baseline run must edit the live config, and #3566 decided that the deployed value stays (a live change of the stage window is a separate decision).

Expected

  • DEVOPS_CLI_AI_TASK_<TASK>_CONTEXT_WINDOW works for the tasks stage, analysis and verification.
  • DEVOPS_CLI_AI_TASK_<TASK>_MAX_TOKENS works for the same tasks.
  • docs/ENV_VARS.md lists them. The generator writes the file: uv run devops docs generate.
  • The variables are optional. A deployed config that does not set them keeps its values. The Settings models ignore unknown keys, but AITasksConfig and AITaskOverride use extra="forbid". This change adds a variable and removes no key, so the live ConfigMap needs no change first (see the go-live check in k8s/README.md).

Acceptance criteria

  • DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW=131072 uv run python -c "from devops_cli.config.settings import load_settings; assert load_settings().ai.for_task('stage').context_window == 131072" passes. It fails today: the value is 262144.
  • The same check passes for analysis and verification, and for MAX_TOKENS. It fails today.
  • uv run pytest tests/config/test_ai_task_settings_paths.py -k context_window passes. The test sets each variable and reads for_task(task). It fails today: the test does not exist.
  • git grep -n "AI_TASK_STAGE_CONTEXT_WINDOW" -- docs/ENV_VARS.md finds the variable. It fails today.
  • uv run devops docs generate leaves no diff in docs/ENV_VARS.md, and uv run pytest tests/test_config_declarations.py passes with the new variables in its set.

Existing tool considered

The Variable marker and the generator of src/devops_cli/config/env.py already declare a variable. This change adds two names to _TASK_VARIABLES and one Variable marker for verification. It adds no new code path and no new library.

Cost

Related

Proposed design

Problem statement

The variable DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW does not exist. The setting is silently ignored and for_task('stage').context_window stays 262144. The stage eval baseline of #3566 needs a window of 131072 for each run without a change to the live config. The task verification has no environment variable at all. The fields context_window and max_tokens already exist on AITaskOverride, so only the variable declarations are missing.

Acceptance criteria

Requirement: Stage context window variable

The settings loader SHALL read DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW into ai.tasks.stage.context_window.

Scenario: Stage window set by variable

  • WHEN The variable DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW is 131072 and load_settings() runs.
  • THEN load_settings().ai.for_task('stage').context_window equals 131072.

Requirement: Window variables for analysis and verification

The settings loader SHALL read DEVOPS_CLI_AI_TASK_ANALYSIS_CONTEXT_WINDOW and DEVOPS_CLI_AI_TASK_VERIFICATION_CONTEXT_WINDOW into the context window of their tasks.

Scenario: Analysis and verification windows set by variable

  • WHEN Each of the two variables is 131072 and load_settings() runs.
  • THEN for_task('analysis').context_window and for_task('verification').context_window both equal 131072.

Requirement: Max tokens variables

The settings loader SHALL read DEVOPS_CLI_AI_TASK_<TASK>_MAX_TOKENS into the max tokens of the tasks stage, analysis and verification.

Scenario: Max tokens set by variable

  • WHEN DEVOPS_CLI_AI_TASK_STAGE_MAX_TOKENS is 4096 and the same variable is set for analysis and verification.
  • THEN for_task(task).max_tokens equals 4096 for each of the three tasks.

Requirement: Unset variables keep values

The settings loader SHALL keep the current values of the window and max tokens when no new variable is set.

Scenario: No new variable

  • WHEN None of the new variables is set and load_settings() runs.
  • THEN for_task('stage').context_window equals 262144 and for_task('stage').max_tokens is None.

Requirement: Invalid value names its variable

The settings loader MUST refuse a value of a new variable that is not a positive integer and MUST name the variable in the error.

Scenario: Bad window value

  • WHEN DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW is abc or 0 and load_settings() runs.
  • THEN load_settings() raises ConfigurationError whose message contains DEVOPS_CLI_AI_TASK_STAGE_CONTEXT_WINDOW.

Requirement: No variable for other tasks

The change SHALL add the two variables only for the tasks stage, analysis and verification.

Scenario: Chat task has no window variable

  • WHEN The set of variable names from setting_variables() is read.
  • THEN The set holds no variable of the tasks chat, metadata or embedding that ends with CONTEXT_WINDOW or MAX_TOKENS.

Requirement: Generated docs list the variables

The file docs/ENV_VARS.md SHALL list the six new variables with a non-empty description, as the generator writes it.

Scenario: Docs match generator

  • WHEN uv run devops docs generate runs after the change.
  • THEN docs/ENV_VARS.md holds the six variable names and the command leaves no diff.

Existing Tool Considered

The Variable marker and the generator in src/devops_cli/config/env.py already declare an environment variable, and pydantic-settings style sources already load it. No outside library is needed. This change adds a tuple of field names, one Variable marker for verification, and two field descriptions. The cost is low: about 10 lines of code, 1 generated doc and 1 test, about 30 minutes, and no upkeep because the generator keeps the doc.

Key questions

  • Which tasks and fields does the change add as variables?: The fields context_window and max_tokens for the tasks stage, analysis and verification, as the issue states. Both fields already exist on AITaskOverride, so config.yaml works already and only the variables are missing. [sources: src/devops_cli/config/settings.py, src/devops_cli/config/env.py, docs/ENV_VARS.md]
  • How does the change declare the new variables without adding them to the chat, metadata and embedding tasks?: Add a new tuple next to _TASK_VARIABLES that holds the four existing fields plus context_window and max_tokens. Use it for analysis and stage. Give verification a Variable marker with only context_window and max_tokens. Leave chat, metadata and embedding on _TASK_VARIABLES. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/env.py]
    • Chosen: New tuple for analysis and stage, and a marker with two fields for verification. It matches the scope of the issue and adds no variable that nobody asked for.
    • Rejected: Add the two fields to _TASK_VARIABLES. It also adds variables for chat, metadata and embedding, which the issue does not ask for and which grow the docs and the test set.
    • Rejected: Give verification the full field set. It adds provider, model and other variables for verification that the issue does not need.
  • Does the generated doc show a description for the new variables?: The generator reads the description of the field. The fields context_window and max_tokens of AITaskOverride have none today. The change adds a short description to both, in the style of the existing fields, so the doc rows are not empty. (best practice) [sources: src/devops_cli/config/settings.py, src/devops_cli/config/env.py]
    • Chosen: Add Field descriptions to the two fields of AITaskOverride. The generator takes the description from the field, so one edit serves the doc and the config help.
    • Rejected: Leave the descriptions empty. The doc rows would be empty and would not tell a person what the variable does.
  • Does the live ConfigMap need a change before this change rolls out?: No. The change adds variables and removes no key. The models AITasksConfig and AITaskOverride keep extra forbid, but no key of config.yaml changes. The variables are optional, so a deployed config keeps its values. [sources: src/devops_cli/config/settings.py, k8s/README.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/config
    status/new
    value/medium
    effort/low
    on Nov 9, 2026
  2. dan-petty commented on Nov 9, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/config. The (config) scope of the title gives the scope.
    • Priority: P2-Medium. It is a prerequisite for the baseline eval in #3566 but does not block production or cause a failure today.
    • Value: Medium. It lets a baseline run set its own window without editing the live config, which #3566 and #4218 both need.
    • Effort: Low. The body states about 2 lines of code, 1 generated doc, and 1 test, roughly 30 minutes.
    • Related: test(roadmap): run the cloud baseline of the stage eval #3566, which asks for a different change. Both concern the stage eval context window, but #3566 runs the baseline eval while the candidate adds the env variable that #3566 needs to set the window per run.
  3. added
    priority/p2-medium
    owner/agent
    on Nov 9, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 9, 2026
  5. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 111adc5 (see proposed design in issue body).

  6. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 9, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 9, 2026
  8. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-09 15:38 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/configsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions