feat(recursion): add adaptive bounded routing #39

Merged
lost-rob0t merged 17 commits from feature/issue-17-adaptive-recursion into main 2026-08-13 04:46:53 +00:00
lost-rob0t commented 2026-08-13 02:37:12 +00:00 (Migrated from github.com)

Summary

  • add a canonical adaptive recursion policy that compares direct continuation, deterministic context work, cheap-submodel delegation, recursive RLM, and supervised-subagent delegation using explicit expected utility vs estimated cost
  • expose normalized routing signals, remaining recursion/call/token budgets, deterministic reasons, and trace metadata for every selected policy
  • cap production recursion at depth 1 unless both explicit deep-recursion opt-in and capability are present
  • add duplicate-subcall fingerprints and no-progress guards so recursive work cannot spin on repeated/stalled subjects
  • harden model-assisted hooks: generators may only rescore already-admitted routes, generated expected_value claims are recomputed, and selectors cannot escape the final bounded candidate set
  • add an executable routing boundary that invokes only caller-supplied route handlers and preserves cancellation/time-limit control exceptions
  • allow handlers to report measured actual_cost, usage, and child identity while preserving backwards compatibility with plain values and ok(Value)
  • record parent/child identity, route reason, estimated cost, actual cost/usage (or explicit unknown), and depth in execution traces
  • expose policy/runtime APIs from the public rlm entrypoint and include both adaptive modules in rlm_ready/0, so static-load CI covers the subsystem
  • wire recursion policy/runtime tests into the complete deterministic PlUnit runner; prior green CI did not execute those files
  • add deterministic policy/runtime matrices for easy direct work, long-context depth-1 recursion, deterministic context operations, cheap models, delegated agents, deep-recursion gating, duplicate/no-progress redirection, hook trust boundaries, measured execution traces, and public load coverage
  • document the adaptive runtime contract and align it with RLM-RESEARCH-008

Architecture

The policy layer has no provider, MCP, tool, or actor side effects. Execution occurs only through explicit route handlers, preserving the existing provider/completion and supervision boundaries. Provider/agent handlers can optionally return measured execution metadata; the policy never invents provider-side cost or usage.

Validation

The exact PR head must pass production/static load, live-test definition load, the complete deterministic PlUnit suite (including adaptive recursion policy/runtime), persistent graph restart, durable artifact restart, whitespace checks, and the existing REAL OpenRouter core + structured-repair gates.

Closes #17

## Summary - add a canonical adaptive recursion policy that compares direct continuation, deterministic context work, cheap-submodel delegation, recursive RLM, and supervised-subagent delegation using explicit expected utility vs estimated cost - expose normalized routing signals, remaining recursion/call/token budgets, deterministic reasons, and trace metadata for every selected policy - cap production recursion at depth 1 unless both explicit deep-recursion opt-in and capability are present - add duplicate-subcall fingerprints and no-progress guards so recursive work cannot spin on repeated/stalled subjects - harden model-assisted hooks: generators may only rescore already-admitted routes, generated `expected_value` claims are recomputed, and selectors cannot escape the final bounded candidate set - add an executable routing boundary that invokes only caller-supplied route handlers and preserves cancellation/time-limit control exceptions - allow handlers to report measured `actual_cost`, usage, and child identity while preserving backwards compatibility with plain values and `ok(Value)` - record parent/child identity, route reason, estimated cost, actual cost/usage (or explicit `unknown`), and depth in execution traces - expose policy/runtime APIs from the public `rlm` entrypoint and include both adaptive modules in `rlm_ready/0`, so static-load CI covers the subsystem - wire recursion policy/runtime tests into the complete deterministic PlUnit runner; prior green CI did not execute those files - add deterministic policy/runtime matrices for easy direct work, long-context depth-1 recursion, deterministic context operations, cheap models, delegated agents, deep-recursion gating, duplicate/no-progress redirection, hook trust boundaries, measured execution traces, and public load coverage - document the adaptive runtime contract and align it with `RLM-RESEARCH-008` ## Architecture The policy layer has no provider, MCP, tool, or actor side effects. Execution occurs only through explicit route handlers, preserving the existing provider/completion and supervision boundaries. Provider/agent handlers can optionally return measured execution metadata; the policy never invents provider-side cost or usage. ## Validation The exact PR head must pass production/static load, live-test definition load, the complete deterministic PlUnit suite (including adaptive recursion policy/runtime), persistent graph restart, durable artifact restart, whitespace checks, and the existing REAL OpenRouter core + structured-repair gates. Closes #17
Sign in to join this conversation.
No description provided.