Routing with Rails: Tool Selection in AiStudio

How the system chooses the right tool without guessing.

Most assistants “stuff context” and hope. AiStudio routes with structure:

The pattern

  1. Classify the request (planner) → decide if it’s local code, infra, or research.
  2. Map to allowed tools:
    • code_tree + read_file for repo discovery
    • search_code for scoped lookup
    • staged_edit_file for atomic writes
    • harness for end‑to‑end exercises
    • SSH tool for live servers (with secrets withheld)
  3. Execute in small batches with a build gate after each coherent slice.

Guardrails

  • No blind edits: a file must be read this turn before it can be staged.
  • No silent failures: every staged_commit builds; red means nothing lands.
  • High‑power tools (SSH, harness) always surface in their own views.

Tiny example

  • Task: add a router client.
  • Route: planner → code read → scaffold via staged writes → harness ping → build gate.
  • Result: deterministic, reviewable, no mystery edits.

Routing here isn’t a black box—it’s a disciplined map from intent to the smallest safe tool path.