Skip to content

fix(roadmap): the consolidate run stops before its 900 s MCP limit #4856

Closed

Description

@dan-petty

Problem Description

PR #4807 (#3745) adds the MCP tool roadmap_consolidate with a 900 s limit (src/devops_cli/config/constants.py:407). The time limits inside this tool are longer than 900 s. This breaks the nested time limit rule (ARCHITECTURE.md:155): each inner time limit is shorter than the limit around it, with a margin.

  • Each judgement makes two sequential chat_structured requests (src/devops_cli/roadmap/consolidate_judge.py:244, :247) with the analysis task client (consolidate_judge.py:281).
  • This client waits the task timeout, else ai.timeout, else DEFAULT_HTTP_TIMEOUT_SECONDS = 3600 s (src/devops_cli/ai/client/unified.py:346-352, src/devops_cli/config/defaults.py:364). The default configuration sets no AI timeout. Thus one request can wait 3600 s, which is longer than the 900 s tool limit.
  • run_consolidate (src/devops_cli/roadmap/consolidate.py:542) has no run budget. It judges up to --limit shortlists, two requests each (consolidate.py:597-602).
  • --limit has min=1 and no maximum (src/devops_cli/commands/roadmap.py:374), and the MCP tool publishes limit.

At 900 s the outer limit stops first. InProcessDispatcher returns exit 124 Command timed out (src/devops_cli/ai/mcp/dispatcher.py:387) with no diagnostic from the run. The command continues on a daemon thread (dispatcher.py:304). It continues to call the model and to write the progress and plan files. A second tool call can start a parallel run. That run reads the same progress file and can judge the same shortlists again. Thus the statement of the archived design of #3745 "the next run does not judge them again" is not always true.

Reproduction Steps

  1. Read the limit row of roadmap consolidate in CONST_MCP_EXPOSURE_TABLE (900 s).
  2. Read the request timeout of the analysis task client with the default configuration (3600 s).
  3. Call the MCP tool roadmap_consolidate with limit set to 20 while the model gateway is slow. The tool returns exit 124 after 900 s, and the run continues on its thread.

Expected vs Actual Behavior

Expected: the chain is model request timeout < consolidate run budget < 900 s tool limit, each with a margin. When the run budget ends, the run starts no new judgement, counts the remaining shortlists as unjudged, writes the plan and exits with a diagnostic. The tool limit does not stop the run.

Actual: the model request timeout (3600 s) is longer than the tool limit (900 s). The run has no budget. The tool limit stops first with no diagnostic, and the run continues on an orphan thread.

Proposed fix:

  • Give run_consolidate a run budget shorter than the tool limit, with a margin (for example 780 s). When the budget ends, start no new judgement, count the remaining shortlists as unjudged and write the plan.
  • Give the judge client a per-request timeout shorter than the run budget (request_timeout_seconds of get_llm_client, or a consolidate setting).
  • Put a maximum on the limit that the MCP tool publishes.
  • Add a chain test, as in openspec/specs/github-session-timeouts, that fails when the request timeout is not shorter than the run budget, or the run budget is not shorter than the 900 s tool limit.

Related: #4678 has the same nested limit problem for the gh MCP resources.

Environment Diagnostics

origin/main after the merge of PR #4807. The finding comes from the independent review of PR #4807. No live run was made.

Logs, Traces, or Terminal Output

None. The evidence is the source lines above.

Source: #4807

Alternatives check of 2026-11-14: none.
Tool: none found.

Proposed design

Problem statement

The roadmap_consolidate MCP tool has a 900 s limit. Its analysis client can wait 3600 s for one model request. run_consolidate has no run budget. The outer limit stops the run with exit 124 and leaves a daemon thread that keeps judging and writing. The fix makes the request timeout shorter than a 780 s run budget and the run budget shorter than the 900 s tool limit. It also caps limit and adds an offline chain test.

Acceptance criteria

Requirement: Consolidate run budget

run_consolidate SHALL stop starting new judgements when its 780 s run budget ends.

Scenario: Budget stops new judgements

  • WHEN The run reaches the 780 s budget before it judges every shortlist.
  • THEN The run writes the plan, starts no new judgement, and reports the remaining shortlists as unjudged.

Requirement: Per-request timeout

Each consolidate judge chat_structured request SHALL use a timeout no longer than 300 s or the remaining budget minus 60 s, whichever is smaller.

Scenario: Short remaining budget

  • WHEN A judge has less than 360 s of run budget left before a model request.
  • THEN The request timeout is the remaining budget minus 60 s, and the judge makes no request when that value is zero or less.

Requirement: Mid-judgement budget check

The consolidate judge SHALL check the run budget before each of its two sequential model requests.

Scenario: Second request would cross the budget

  • WHEN The first model request leaves less than 60 s of the run budget.
  • THEN The judge makes no second request and counts the shortlist as unjudged.

Requirement: Command limit maximum

The roadmap consolidate command SHALL reject a limit above 20.

Scenario: Limit above maximum

  • WHEN A caller passes limit=21.
  • THEN The command returns a validation error that names the maximum 20 and starts no judgement.

Requirement: Published limit maximum

The roadmap_consolidate MCP tool schema SHALL publish a maximum of 20 for limit.

Scenario: Tool schema shows maximum

  • WHEN A client reads the input schema of roadmap_consolidate.
  • THEN The limit property has maximum set to 20.

Requirement: Partial run diagnostic

A consolidate run that reaches its budget SHALL exit 0 and write a diagnostic that names the unjudged shortlist count.

Scenario: Budget ends with unjudged shortlists

  • WHEN The run budget ends before every shortlist is judged.
  • THEN The command writes the plan, prints the unjudged count to stderr, and exits 0.

Requirement: Chain test

A test SHALL fail when request timeout is not below run budget or run budget is not below 900 s tool limit.

Scenario: Broken timeout chain

  • WHEN The test reads a request timeout of 780 s or a run budget of 900 s.
  • THEN The test fails and names the two limits that break the chain.

Requirement: Request timeout counts unjudged

A consolidate judge request that reaches its per-request timeout SHALL count its shortlist as unjudged and SHALL NOT abort the run.

Scenario: Model request times out

  • WHEN The fake judge client raises a request timeout for one shortlist.
  • THEN The run writes the plan with that shortlist unjudged and judges the next shortlist when budget remains.

Existing Tool Considered

No open, maintained tool covers the need. The alternatives check found tenacity and anyio, but both only enforce deadlines. They cannot stop new judgements, count unjudged shortlists, write the plan with a diagnostic, cap the published limit, or assert the nested chain. The project must build this in its own consolidate code. The written cost is about 6,000 tokens and 3 hours to build, keep and fix.

Key questions

  • What is the MCP tool limit for roadmap_consolidate?: 900 s. [sources: src/devops_cli/config/constants.py]
  • What is the default timeout of the analysis task client?: DEFAULT_HTTP_TIMEOUT_SECONDS is 3600 s, and the default configuration sets no ai.timeout. [sources: src/devops_cli/ai/client/unified.py, src/devops_cli/config/defaults.py]
  • What run budget keeps run_consolidate inside the 900 s MCP tool limit?: 780 s. (best practice) [sources: src/devops_cli/config/constants.py, ARCHITECTURE.md]
    • Chosen: 780 s. It leaves a 120 s margin below the 900 s tool limit and matches the issue proposal.
    • Rejected: 900 s. It equals the tool limit, so the outer limit can still stop the run first.
    • Rejected: 600 s. It leaves a larger margin but cuts useful work before the budget needs to stop.
  • What per-request timeout keeps two judge requests inside the run budget?: 300 s, capped by the remaining budget minus 60 s. (best practice) [sources: src/devops_cli/ai/client/unified.py, src/devops_cli/roadmap/consolidate_judge.py, src/devops_cli/config/defaults.py]
    • Chosen: 300 s with remaining-budget cap. Two 300 s requests fit in 780 s, and the cap stops a request before the deadline.
    • Rejected: Use the analysis task timeout. The default can be 3600 s, which is longer than the run budget.
    • Rejected: Half the run budget. Two 390 s requests use the whole budget and leave no margin.
  • Where does the consolidate run check its budget?: Before each shortlist and before each of the two model requests in a judgement. (best practice) [sources: src/devops_cli/roadmap/consolidate.py, src/devops_cli/roadmap/consolidate_judge.py, src/devops_cli/ai/mcp/dispatcher.py]
    • Chosen: Deadline passed to judge and checked before each request. A check only between shortlists can let the second request cross the budget.
    • Rejected: Check only between shortlists. The second request can start after the budget and run to its own timeout.
    • Rejected: Rely on the MCP tool timeout. It returns exit 124 and leaves the run on a daemon thread.
  • What maximum should the limit option publish?: 20 shortlists. (best practice) [sources: src/devops_cli/commands/roadmap.py, src/devops_cli/config/constants.py]
    • Chosen: 20 shortlists. It bounds one run at the high value in the issue reproduction, and the run budget still bounds time.
    • Rejected: No maximum. A caller can ask for an unbounded number of judgements.
    • Rejected: 100 shortlists. It accepts a much larger batch and gives no extra safety over the budget.
  • What exit status and diagnostic does a budget-limited consolidate run give?: Exit 0 with a warning that names the unjudged count. (best practice) [sources: src/devops_cli/roadmap/consolidate.py, src/devops_cli/ai/mcp/dispatcher.py]
    • Chosen: Exit 0 with warning. The plan is written and the progress file is valid, so the next run can continue.
    • Rejected: Exit 75. The run did not fail for a transient reason; it completed its budget.
    • Rejected: Exit 1. A typed stop would mark a valid partial plan as an error.
  • What happens when one judge request reaches its per-request timeout?: The run counts that shortlist as unjudged and continues when budget remains. (best practice) [sources: src/devops_cli/roadmap/consolidate_judge.py, src/devops_cli/roadmap/consolidate.py]
    • Chosen: Count unjudged and continue. One slow model call must not discard the plan or repeat completed judgements.
    • Rejected: Abort the run. The plan is lost and the next run repeats work.
    • Rejected: Retry the request. A retry can consume the remaining budget and cross the run deadline.
  • How does the chain test verify the nested limits?: An offline test reads the configured request timeout, run budget, and 900 s tool limit and asserts request < run < tool. (best practice) [sources: tests/roadmap/test_roadmap_consolidate_judge.py, src/devops_cli/config/constants.py]
    • Chosen: Offline configuration test. It fails at the boundary before a live model call and is deterministic.
    • Rejected: Live integration test. It is slow, needs a model gateway, and is not deterministic.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. The orphan thread can judge the same shortlists twice, but only when the model gateway is slow enough to hit the 900 s limit.
    • Value: Medium. It prevents duplicate judgements and silent exit-124 failures in the consolidate run.
    • Effort: Medium. The fix needs a run budget, a per-request timeout, a max on limit, and a chain test, each a small code change.
    • Related: feat(roadmap): consolidate has an MCP mirror and a weekly row #3745, which asks for a different change. #3745 delivered the MCP tool roadmap_consolidate; this candidate is a defect found in that delivery where the inner timeouts exceed the outer 900 s limit.
  3. added
    priority/p2-medium
    on Nov 11, 2026
  4. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches for an MCP tool timeout/budget library and for a Python nested-deadline mechanism returned only generic timeout documentation (WebDriver, DOM setTimeout, HTTP 504) and no project or package that provides a budget-aware consolidate loop. The closest general primitives (anyio deadline scopes, tenacity stop_after_delay) can only raise or cancel at a deadline; they cannot stop starting judgements, count remaining shortlists as unjudged, write the plan with a diagnostic, cap the published limit, or assert the request-timeout < run-budget < 900 s chain, so the fix stays in the project's own consolidate code.

    Tool: none found

    Lacks:

    • No tool provides a run budget for run_consolidate that stops new judgements and records the remaining shortlists as unjudged
    • No tool supplies a per-request timeout for the consolidate judge client that is shorter than the run budget
    • No tool bounds the limit that the MCP roadmap_consolidate tool publishes
    • No tool provides the chain test that the request timeout is shorter than the run budget and the run budget shorter than the 900 s tool limit
    • Deadline primitives only cancel at a deadline; they do not write the plan and exit with a diagnostic instead of leaving an orphan thread

    Tools considered:

    Searches run:

    • MCP tool call timeout budget nested timeouts library, results: 5
    • Python library run budget deadline propagation timeout hierarchy, results: 5
    • anyio fail_after cancellation scope nested deadline pattern, results: 5
    • MCP Python SDK server tool execution timeout configuration, results: 5
    • python package enforce nested timeout margin test, results: 5
    • "timeout" budget pattern batch job stop starting new work remaining time, results: 5
    • FastMCP tool timeout parameter, results: 5
    • tenacity stop_after_delay total run deadline, results: 5
    • mcp python sdk timeout github, results: 5
    • pytest-timeout PyPI, results: 5

    Sources:

    Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.

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

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    Live since 2026-11-19 06:26 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/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions