Skip to content

Declare agent loop type in routing.json; unify cmd_run_agent dispatcher #17

Description

@zomars

Parent

#12

What to build

Agent loop type becomes routing data. providers/<name>/routing.json gains a new agent-level field:

{
  "agents": {
    "implementer": { "loop": "backlog",   "rules": { ... } },
    "fixer":       { "loop": "github-pr", "rules": { ... } },
    ...
  }
}

Valid values to start: "backlog" and "github-pr". A future loop type means adding a new value and a new source-file mapping in the dispatcher — no bin/ralph case-statement edits, no new cmd_*_agent function.

bin/ralph's dispatcher collapses:

  • cmd_agent + cmd_github_agent → one cmd_run_agent(agent_key) that:
    1. Reads the agent's loop field from the active provider's routing.json.
    2. Sources the matching loop library (ralph-gated-loop.sh for "backlog", ralph-github-loop.sh for "github-pr").
    3. Calls the matching ralph_<loop>_loop function with the standard arguments.
  • The top-level case statement's two agent-list branches merge into one branch covering all agents.

All existing routing.json files (jira, linear, github-issues, github-projects, file) gain the loop field for every agent already listed. Validator (whether today's monolith or the refactor from #16) enforces presence and known values.

Acceptance criteria

  • Every agent in every provider's routing.json declares a loop field with a valid value.
  • bin/ralph dispatcher has a single cmd_run_agent covering every agent; cmd_agent and cmd_github_agent are gone.
  • Top-level case has a single branch listing all agents, routed through cmd_run_agent.
  • Running each existing agent (ralph planner --once, ralph implementer --once, …, ralph fixer --once, ralph merger --once, ralph pr-reviewer --once) sources the correct loop library and behaves identically to today.
  • An agent with a missing loop field is rejected with a clear error message at dispatch time.
  • An agent with an unknown loop value is rejected with a clear error message at dispatch time.
  • Behaviour-level tests cover: dispatch picks the correct loop library for each (provider, agent) pair; missing/unknown loop value is rejected; golden output comparison of ralph debug <agent> --preview-prompt before and after the refactor matches for every agent.
  • Tests follow the existing tests/ harness conventions.
  • CLAUDE.md and CONTEXT.md updated where they describe the two-loop split — replace with the routing-data formulation.

Blocked by

None — can start immediately.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestready-for-agentTriaged, ready for an autonomous agent to pick upstatus:to-doNot yet started

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions