[P0] Implement rlm_completion/4 with depth-1 recursion, budgets, cancellation, and tracing #9

Closed
opened 2026-08-12 01:18:26 +00:00 by lost-rob0t · 0 comments
lost-rob0t commented 2026-08-12 01:18:26 +00:00 (Migrated from github.com)

Goal

Deliver the first real Recursive Language Model loop in SWI-Prolog.

Scope

  • implement rlm_completion/4, llm_query/..., and depth-1 rlm_query/...;
  • let the root model inspect context metadata/handles and select a validated plan;
  • execute context/model/tool actions through the typed interpreter;
  • support final-answer/final-result termination semantics;
  • enforce iteration, recursion-depth, concurrent-subcall, wall-time, token, and cost budgets;
  • propagate cancellation through nested calls;
  • detect obvious duplicate/cyclic recursive calls;
  • emit a structured trajectory with parent/child relationships and usage.

Acceptance criteria

  • one end-to-end run uses a real provider, external context, a model-selected plan, one tool, and one depth-1 recursive call;
  • configured budgets terminate pathological loops deterministically;
  • recursion cannot exceed the configured hard maximum;
  • cancellation stops pending/nested work and cleans up resources;
  • trace records why recursion happened plus estimated/actual usage;
  • direct non-recursive completion remains possible when decomposition is unnecessary.

Dependencies

Research

See RLM-RESEARCH-002-agentic-harness.org, RLM-RESEARCH-003-typed-symbolic-execution.org, and RLM-RESEARCH-008-adaptive-recursion.org.

## Goal Deliver the first real Recursive Language Model loop in SWI-Prolog. ## Scope - implement `rlm_completion/4`, `llm_query/...`, and depth-1 `rlm_query/...`; - let the root model inspect context metadata/handles and select a validated plan; - execute context/model/tool actions through the typed interpreter; - support final-answer/final-result termination semantics; - enforce iteration, recursion-depth, concurrent-subcall, wall-time, token, and cost budgets; - propagate cancellation through nested calls; - detect obvious duplicate/cyclic recursive calls; - emit a structured trajectory with parent/child relationships and usage. ## Acceptance criteria - one end-to-end run uses a real provider, external context, a model-selected plan, one tool, and one depth-1 recursive call; - configured budgets terminate pathological loops deterministically; - recursion cannot exceed the configured hard maximum; - cancellation stops pending/nested work and cleans up resources; - trace records why recursion happened plus estimated/actual usage; - direct non-recursive completion remains possible when decomposition is unnecessary. ## Dependencies - #5 - #6 - #7 - #8 - parent #3 ## Research See `RLM-RESEARCH-002-agentic-harness.org`, `RLM-RESEARCH-003-typed-symbolic-execution.org`, and `RLM-RESEARCH-008-adaptive-recursion.org`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nsaspy/prolog-rlm#9
No description provided.