Skip to content

[P0][Routing] Integrate worker-agent-hybrid execution decisions into the production runner #694

Description

@wesleysimplicio

Objective

Make every production work item pass through the deterministic execution-route decision before an LLM or effect executor is selected.

The repository already defines simplicio.execution-route/v1 and decide_route(), but current references are limited to its module/tests. The main runner does not consume the receipt as an authoritative routing gate.

Routing authority

  • Worker: mapping, indexed search, dedupe, mechanical edit, schema validation, tests, diff and receipt publication when deterministic capability exists.
  • Agent: ambiguous intent, plan synthesis, non-mechanical code/copy, new failure investigation, semantic review and recovery choice.
  • Hybrid: deterministic gates first; invoke an agent only on inconclusive evidence or explicit semantic judgment.
  • Runtime enforces physical/resource/policy constraints but does not make semantic decisions.
  • Any compatible coordinator may be the agent; Simplicio Agent is not mandatory.

Implementation steps

  1. Add route decision as a required runner stage after intake/context and before planning/execution.
  2. Replace keyword-only production behavior with versioned capability-aware rules while retaining deterministic fixtures.
  3. Consume Mapper evidence/ContextGraph handles to classify scope and ambiguity without re-reading the tree.
  4. Query installed worker capabilities from Mapper, Dev CLI and optional Runtime.
  5. Persist the route receipt with task, evidence handles, confidence, backend candidates and causal IDs.
  6. Route worker tasks without an LLM call.
  7. Route agent tasks through the selected runtime driver, pinning coordinator/provider/model identity for the attempt.
  8. For hybrid tasks, record each deterministic gate and the precise escalation reason.
  9. Re-evaluate only when new evidence invalidates the route; prevent oscillation worker↔agent.
  10. Share token/resource budget across retries and fan-out.
  11. Replace fabricated zero token fields with measured values or UNAVAILABLE/null plus reason.
  12. Surface the route in status, progress, handoff and final receipts.

Tests

  • Mechanical edit with available worker: zero LLM calls.
  • Mechanical task with missing worker: hybrid and explicit repair/escalation.
  • Ambiguous goal: agent route.
  • Mixed task: deterministic preflight then one bounded agent escalation.
  • Changed capability manifest invalidates cached route.
  • Stale Mapper evidence is rejected.
  • Retry does not silently change provider/model.
  • Multi-item drain chooses routes independently.
  • Route oscillation and budget exhaustion.
  • Equivalent route receipt across two coordinator hosts.

Acceptance criteria

  • Every production item has a verified execution-route receipt before work begins.
  • Deterministic work does not invoke an LLM.
  • Agent escalation includes machine-readable evidence and reason.
  • Runtime resource denial cannot be misreported as semantic routing.
  • Route decisions are stable, replayable and invalidated by explicit evidence changes.
  • Token fields are measured or unavailable with a reason.
  • Runner, CLI status and final delivery expose the same route identity.
  • Unit, integration, regression and E2E tests pass locally/containerized.
  • Benchmark compares completion, tokens, latency and retries before/after.

Relations

  • Runtime ownership: wesleysimplicio/simplicio-runtime#3134
  • Token economy: wesleysimplicio/simplicio-runtime#3086

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions