Skip to content

feat(ai): ai gateway and rag commands take the API route names #5236

Open

Description

@dan-petty

Problem or Motivation

The owner asked on 2026-11-12 that a devops command on an HTTP API take its names from the API routes (ADR 0026, #5223). Sources: commands/ai_gateway.py, ai/gateway.py, commands/ai.py, commands/rag.py and ai/ai_plans.py.

devops command Route
ai gateway routes GET /model/info
ai preload and ai prewarm Both send POST /api/generate with keep_alive to each Ollama server.
ai rag query and ai rag search One command at two paths. The dry-run plan names points/search, but the code calls query_points (POST /collections/{c}/points/query).
ai gateway status GET /health/readiness, then GET /health. It reads two routes.

Agents use the MCP tools ai_gateway_status and ai_gateway_routes. Loki holds no usage error for this group in the 7 days to 2026-11-12.

Proposed Solution & Architectural Design

  • Rename ai gateway routes to ai gateway model info, from the LiteLLM route /model/info. The two segments give two words. The MCP description of ai_gateway_model_info starts with devops ai gateway model info (feat(cli): tool commands pass unknown arguments to the tool #5223).
  • ai gateway status reads two routes, so it is a composite with a project verb, and its name stays. Premise check: confirm in the LiteLLM proxy reference that no route uses the word status with another meaning. Record also if the second read of GET /health, which calls each model deployment, stays. If it goes, the command reads one route and becomes ai gateway health readiness.
  • Fold ai preload into ai prewarm, which has --keep-alive for the route field keep_alive. The old preload is prewarm --keep-alive -1 on all servers. prewarm sends one request to each server, so it is a composite, and Ollama has no route prewarm.
  • Remove ai rag search, the second path of ai rag query. Correct the plan route to POST /collections/{c}/points/query. ai rag query embeds the text and then queries Qdrant, so it is a composite. The Qdrant route word query has the same meaning, so it stays.
  • Change the MCP row ai gateway routes.
  • Add ai gateway to the groups of tests/commands/test_api_command_names.py.

Target Subsystem

AI (devops ai gateway, devops ai rag, devops ai prewarm).

Existing Tool Considered

The LiteLLM proxy, Ollama and Qdrant API references give the names. Nothing is built.

Acceptance Criteria

  • devops ai gateway model info --dry-run prints GET /model/info and sends 0 requests.
  • devops ai rag query --dry-run prints POST /collections/<c>/points/query.
  • devops ai gateway routes, devops ai preload and devops ai rag search exit 2.
  • tests/commands/test_api_command_names.py passes for ai gateway.
  • devops docs check passes.

Dependencies

Open the pull request after the pull request of #5234 merges (generated command reference, CONST_MCP_EXPOSURE_TABLE, the API name test).

Source: #5223

Alternatives check of 2026-11-22: none.
Tool: none found.
Reason: Searches found OpenAPI-to-CLI generators (Restish, smtpfast-cli) that map routes to commands in a generated CLI, but none renames commands, dry-run plans, MCP rows and tests inside this hand-written Typer CLI.

Lacks:

  • Rename existing commands inside a hand-written Typer CLI
  • Dry-run plans that print the exact HTTP request path
  • Update MCP exposure table, generated docs and name test

Proposed design

Problem statement

Do not start until a person breaks the dependency cycle #5236 → #5234 → #5232 → #5228 → #5236 and #5234 merges. The AI commands do not take the names of the HTTP routes that they call. ADR 0026 and #5223 require one command word for each route word. This change renames ai gateway routes to ai gateway model info, folds ai preload into ai prewarm, removes ai rag search, corrects the ai rag query dry-run route, and updates the MCP row, name test and generated documents.

Acceptance criteria

Requirement: Gateway model info dry run

The devops ai gateway model info command SHALL print GET /model/info in its dry-run plan and SHALL send no request.

Scenario: Dry run of model info

  • WHEN A test runs devops ai gateway model info --dry-run with a fake gateway client.
  • THEN The output holds GET /model/info and the fake client records 0 requests.

Requirement: Gateway status reads both health routes

The devops ai gateway status command SHALL keep its name and SHALL send GET /health/readiness then GET /health when the first route fails.

Scenario: Status reads both health routes

  • WHEN A test runs devops ai gateway status with a fake gateway client that returns 503 for /health/readiness and 200 for /health.
  • THEN The fake client records a GET /health/readiness request and then a GET /health request.

Requirement: Prewarm keep alive

The devops ai prewarm command SHALL accept --keep-alive -1 and SHALL send POST /api/generate with keep_alive set to -1 to each Ollama server.

Scenario: Preload behavior through prewarm

  • WHEN A test runs devops ai prewarm --keep-alive -1 with two fake Ollama servers.
  • THEN Each fake server receives one POST /api/generate request with keep_alive -1.

Requirement: RAG query dry run route

The devops ai rag query command SHALL print POST /collections/c/points/query in its dry-run plan for collection c and SHALL send no request.

Scenario: Dry run of RAG query

  • WHEN A test runs devops ai rag query --dry-run for collection c.
  • THEN The output holds POST /collections/c/points/query and the fake client records 0 requests.

Requirement: Old AI command names exit 2

The commands ai gateway routes, ai preload and ai rag search SHALL exit with code 2.

Scenario: Old command names are absent

  • WHEN A test invokes devops ai gateway routes, devops ai preload and devops ai rag search with no option.
  • THEN Each invocation exits with code 2.

Requirement: MCP exposure row follows the rename

The MCP exposure table SHALL name the path ai gateway model info in place of ai gateway routes, so the server publishes the tool ai_gateway_model_info.

Scenario: Exposure table holds the new row

  • WHEN A developer runs uv run pytest tests/ai/mcp/test_mcp_exposure_table.py.
  • THEN The test passes, each exposed path resolves to a command of the tree, and the server holds the tool ai_gateway_model_info.

Requirement: API command name test group

The API command name test SHALL include ai gateway in its groups and SHALL pass.

Scenario: API command name test for gateway

  • WHEN A developer runs uv run pytest tests/commands/test_api_command_names.py.
  • THEN The test passes and its group list holds ai gateway.

Requirement: Documentation check

The generated command reference and the MCP documents SHALL match the renamed commands.

Scenario: Documentation check after the rename

  • WHEN A developer runs uv run devops docs check.
  • THEN The command exits 0 and reports no stale generated document.

Existing Tool Considered

The alternatives check of 2026-11-22 in the issue body is the source; it names no tool. No open, maintained tool covers the need, because the change renames commands inside this hand-written Typer CLI. The proposal edits the Typer command modules, the plan strings in ai_plans.py, the MCP exposure table, the name test and the generated documents. It adds no dependency and builds no library. Cost: about 2 hours of elapsed work and an estimated 100,000 tokens to make the rename, its tests and the regenerated documents.

Key questions

  • Which command name replaces ai gateway routes for the LiteLLM route GET /model/info?: Rename it to ai gateway model info. The route holds the two words model and info, and the rule of feat(cli): tool commands pass unknown arguments to the tool #5223 gives one command word for each route word. (best practice) [sources: src/devops_cli/ai/gateway.py, src/devops_cli/config/constants.py:306, src/devops_cli/commands/ai_gateway.py]
    • Chosen: ai gateway model info. It uses the two words of GET /model/info in route order.
    • Rejected: ai gateway routes. It names no route word and keeps the old name.
    • Rejected: ai gateway model-info. It joins two route words into one segment and adds a punctuation mark.
  • Does ai gateway status keep its name and both health reads?: Keep the name and both reads. _probe_gateway_http sends GET /health/readiness and then GET /health when the first route fails. The command reads two routes, so it is a composite with a project verb. The code holds no route that uses the word status with another meaning. (best practice) [sources: src/devops_cli/ai/gateway.py:469, tests/ai/mcp/test_ai_gateway.py]
    • Chosen: Keep ai gateway status with both reads. It names the composite command and keeps the /health fallback that the code makes.
    • Rejected: Rename to ai gateway health readiness. It names one route and hides the second read.
    • Rejected: Rename to ai gateway health. It does not show that the command reads two health routes.
  • Should ai preload fold into ai prewarm?: Fold ai preload into ai prewarm. Both send POST /api/generate with keep_alive, and prewarm --keep-alive -1 gives the old behavior of preload. prewarm sends one request to each Ollama server, so it is a composite, and Ollama has no route prewarm. (best practice) [sources: src/devops_cli/ai/ai_plans.py, src/devops_cli/commands/ai.py]
    • Chosen: Fold preload into ai prewarm. One command sends the same route and keeps the keep_alive field.
    • Rejected: Keep preload and prewarm. Two commands send the same POST /api/generate request.
    • Rejected: Rename preload to generate. It duplicates prewarm, which already sends POST /api/generate to each server.
  • Should ai rag search stay, and which route does the ai rag query plan name?: Remove ai rag search and keep one ai rag query. The plan must name POST /collections/{collection}/points/query, because the code calls query_points and not points/search. The command embeds the text and then queries Qdrant, so it is a composite, and the route word query stays. (best practice) [sources: src/devops_cli/commands/rag.py, src/devops_cli/ai/ai_plans.py]
    • Chosen: Remove ai rag search. One command has one route, and the second name hides that both paths call the same query.
    • Rejected: Keep ai rag search as an alias. Two command names for one Qdrant route break the route-name rule.
    • Rejected: Rename query to search. The code calls query_points at points/query, not points/search.
  • How do the MCP exposure table, the API name test and the generated documents follow the rename?: Change the CONST_MCP_EXPOSURE_TABLE row from ai gateway routes to ai gateway model info. Add ai gateway to the groups of tests/commands/test_api_command_names.py. Regenerate the command reference and the MCP documents, and run devops docs check. (best practice) [sources: src/devops_cli/config/constants.py:306, src/devops_cli/ai/mcp/generator.py, tests/ai/mcp/test_mcp_exposure_table.py, docs/CLI_REFERENCE.md]
    • Chosen: Update the table, the test and the documents. The tool name and the command name stay equal, and the API name test covers the new group.
    • Rejected: Keep the old table row. The MCP tool would name a command that exits 2, and the exposure test would fail.
    • Rejected: Update the table only. The API name test would not cover ai gateway.

Fit

Fits in one pull request.

Suspected block

The item is in a dependency cycle #5236 → #5234 → #5232 → #5228 → #5236; a person must remove one edge before work starts.
The item is in a dependency cycle: #5236 → #5234 → #5232 → #5231 → #5230 → #5229 → #5236. A person removes one edge of the cycle, so that its items no longer wait on each other.

Dependencies

#5234

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/feature
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 4d085f1 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  6. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    One more plan of the same family names a request that the command does not make, found on 2026-11-21 (main 11fee3f):

    • devops ai rag clear --dry-run prints DELETE /collections/devops-code and DELETE /collections/devops-docs. The real run deletes the configured collections from resolve_rag_components() (src/devops_cli/commands/rag.py:602-608), which are devops_code and devops_docs on this workstation (devops ai rag status).
    • Cause: plan_ai_rag_clear and the other rag plans in src/devops_cli/ai/ai_plans.py (lines 434, 454, 467, 505, 526 and 553) hard-code devops-code and devops-docs in place of the configured names.
    • Fix with this item: each rag plan reads the collection names from the same resolver as the command, and a test runs the plan with configured names that differ from the old literals.
  8. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    Owner question: See the first point of Open questions in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  9. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (3)

    Searches run:

    • rename CLI commands to match REST API route names tool, results: 5
    • generate CLI commands from OpenAPI spec automatically tool, results: 5
    • restish generate CLI commands from OpenAPI specification, results: 5

    Sources:

  10. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  11. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Owner question: See Suspected block in the section Proposed design of the body.

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

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/aisource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions