Skip to content

feat(roadmap): a model ladder for retries, with the tier chosen per attempt #3060

Closed

Description

@dan-petty

What happened

Every attempt of a step uses the same model tier. The Service runs on the homelab tiers, and the XML tool-call parser bug of one model family (#2953) fails the same call every time it is repeated. A harder step gets no stronger model.

What should happen

  • A ladder in config: tier per attempt and per step class (plan, edit, repair, review), for example a fast local model first, a stronger local tier on round 2, a configured fallback tier on round 3. Gateway tier health is read before a choice.
  • A step that fails on a provider error moves down the ladder without spending a repair round.

Acceptance criteria

  • A replay with a provider error on tier 1 succeeds on tier 2 and the trace names both.
  • The ladder is a setting and devops config show prints it.
  • The token cost per tier is recorded per item.
  • No hosted-provider call happens unless the setting names one.

Related: tracker for this set (filed with it), #2908 (issue workflow), #2867 (draft PR evaluator), #3005 (task kind), #3010 to #3015 (plan gates), #2919 (stuck-item metrics), #2953 (Ollama parser).

Proposed design

Problem statement

Every retry of a step uses the same model tier. A model-specific defect, such as the Ollama XML parser bug (#2953), fails the same call on every repeat. A step that needs a stronger model gets none. This issue adds a tier ladder so each attempt can use a different tier, and a provider error moves the step to the next tier without spending a repair round.

Acceptance criteria

Requirement: Ladder config

The ladder SHALL be a config setting that maps each step class to a list of tiers, one per attempt.

Scenario: config show prints the ladder

  • WHEN a ladder is set and devops config show is run
  • THEN the output lists the tier for each attempt of each step class

Requirement: Provider error tier move

A step that fails on a provider error SHALL advance to the next tier without incrementing the repair round counter.

Scenario: replay with provider error on tier 1

  • WHEN a step fails with a provider error on tier 1
  • THEN the next attempt uses tier 2 and the trace names both tiers

Requirement: Token cost per tier

The token cost SHALL be recorded per tier per item in the item trace.

Scenario: cost recorded after a step completes

  • WHEN a step completes on a given tier
  • THEN the item trace includes the token count attributed to that tier

Requirement: No hosted provider unless configured

No hosted-provider call SHALL happen unless the ladder setting names one.

Scenario: default ladder names only local tiers

  • WHEN the ladder setting names only local tiers
  • THEN no request is sent to a hosted provider

Requirement: Gateway tier health check

Gateway tier health SHALL be read before a tier is chosen for an attempt.

Scenario: unhealthy tier is skipped

  • WHEN a tier in the ladder is reported unhealthy by the gateway
  • THEN the step skips that tier and uses the next healthy tier

Existing Tool Considered

No check has run. The project builds its own ladder logic on top of its existing model routing. The written cost is the tokens to implement the config schema, the tier-advancing retry logic, the gateway health check, and the per-tier cost tracking, plus the tokens to keep and fix that code until it matches a general-purpose router.

Key questions

  • How is the ladder configured?: A new config key holds a map of step class (plan, edit, repair, review) to a list of tiers, one per attempt. The list is ordered from weakest to strongest tier. (proposed)
    • Chosen: Per-step-class list of tiers. The body states tier per attempt and per step class. This allows a fast local model for plan and a stronger tier for repair.
    • Rejected: Single global list of tiers. Simpler, but does not allow different ladders for different step classes. The body requires per-step-class.
    • Rejected: Per-attempt only, no step class. Does not distinguish plan from repair. The body requires per-step-class.
  • How does a provider error trigger a tier move without spending a repair round?: The step executor catches a provider error (HTTP 4xx or 5xx from the model gateway) and advances the attempt index. The repair round counter is not incremented. The next attempt uses the next tier in the ladder. (proposed)
    • Chosen: Catch provider error and advance tier. The body states a provider error moves the step down the ladder without spending a repair round. This is the direct reading.
    • Rejected: Treat as a normal failure and use a repair round. Wastes a repair round on a model defect. The body explicitly avoids this.
    • Rejected: Retry same tier with backoff. Does not help when the defect is in the model itself, as in chore(k8s): bump Ollama image for qwen3-coder parser fix #2953.
  • How is gateway tier health read before a choice?: Before choosing a tier for an attempt, the executor queries the gateway health endpoint for that tier. An unhealthy tier is skipped and the next tier in the ladder is used. (proposed)
    • Chosen: Query gateway health before each choice. The body states gateway tier health is read before a choice. This is the direct reading.
    • Rejected: Cache health for a TTL. Adds complexity and a stale-cache risk. The body does not mention caching.
    • Rejected: No health check. The body requires a health check. Rejecting it contradicts the requirement.
  • How is token cost per tier recorded per item?: Each step completion records the tier used and the token count in the item trace, keyed by tier. The trace accumulates one entry per tier per item. (proposed)
    • Chosen: Per-tier token count in item trace. The body states the token cost per tier is recorded per item. This is the direct reading.
    • Rejected: Aggregate total only. Loses the per-tier breakdown. The body requires per-tier.
    • Rejected: Per-step only, no tier key. Does not attribute cost to a tier. The body requires per-tier.
  • Which existing tool or library covers the need for a per-step-class model tier ladder with gateway health checks and per-tier cost tracking?: No check has run. LiteLLM (BerriAI/litellm) provides fallback routing between models, but it does not provide per-step-class ladders, gateway tier health checks before choice, or per-tier token cost tracking per item. The project builds its own ladder logic on top of its existing model routing. [sources: docs/adr/0005-review-findings-come-from-tools-not-models.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 1, 2026
  2. dan-petty commented on Nov 1, 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/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Improves retry resilience but does not block current functionality; no security or data-loss risk.
    • Value: Medium. Reduces wasted calls and lets harder steps reach a stronger model, but the service already retries with a fixed tier.
    • Effort: Medium. Requires new config schema, gateway health read, per-attempt routing logic, and trace/cost recording.
    • Related: feat(roadmap): every step repairs before it gives up, in bounded rounds #3053, which asks for a different change. Both concern what the step does after a failure; #3053 delivers the bounded-round retry loop, the candidate delivers the specific tier-selection ladder and provider-error routing within it.
  3. added
    priority/p2-medium
    on Nov 1, 2026
  4. dan-petty commented on Nov 1, 2026

    @dan-petty
    OwnerAuthor

    Live evidence (2026-11-01): 2 of 13 stops were HTTP 400 ... XML syntax error on line 35/70: unexpected EOF from Ollama (#2559, #2462; upstream ollama/ollama 18563). Each ran on the same model tier and ended the item at the first error. A retry on a second tier, or on the same tier with a smaller step, is the case this ladder serves.

  5. added
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 853987e (see proposed design in issue body).

  7. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch feat/3060-a-model-ladder-for-retries-with, draft pull request #3225. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add the ladder setting: 6439 tokens
    2. Show the ladder in config show: 6443 tokens
    3. Choose the tier per attempt and move on a provider error: 6495 tokens
    4. Read gateway tier health before choosing a tier: 6478 tokens
    5. Record token cost per tier in the run record: 6479 tokens
    6. Write the change documents: 6532 tokens

    The plan run made 5 model request(s), and used 236750 input tokens and 6553 output tokens. The tool calls, in order:

    1. list_files({"directory":""})
    2. list_files({"directory":"src"})
    3. search_code({"text":"tier"})
    4. search_code({"text":"config show"})
    5. search_code({"text":"devops-coder"})
    6. search_code({"text":"implement"})
    7. search_code({"text":"gateway"})
    8. search_code({"text":"step_class"})
    9. list_files({"directory":"src/devops_cli/roadmap"})
    10. list_files({"directory":"tests/roadmap"})

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • task_order at group 3: The group 3 test needs the run record to name both tiers. Group 5 builds that record in implement_run.py, and group 3 does not change that file. The test cannot pass at group 3. Evidence: "Add a failing replay test where tier 1 returns a provider error, tier 2 succeeds, and the run record names both tiers"
    • other at group 2: config show prints only keys from setting_variables() and secret_keys(). The plan registers no variable for the ladder, for example in config/env.py. The ladder would not appear in the output, and group 2 changes only commands/config.py. Evidence: "for key in sorted(setting_variables().keys() | secret_keys())"
    • criterion_dropped at criteria (group 1): The plan maps the no-hosted-call criterion to group 1. That group tests only the default value and adds no task to stop hosted calls when the ladder names only local tiers. The step code of groups 3 and 4 has no such task either. Evidence: "Add a failing test that the ladder maps each step class to an ordered tier list and that the default names only local tiers"
  8. added 3 commits that reference this issue on Nov 2, 2026
  9. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  10. added
    status/in-review
    and removed
    status/planned
    on Nov 3, 2026
  11. removed
    status/in-review
    on Nov 3, 2026
  12. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor
  13. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-03 20:33 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions