fix: route harness direct/complete through the context compiler #96

Closed
nsaspy wants to merge 0 commits from fix/context-compiler-unused into main
Owner

Summary

Routes every prolog_rlm network action through the Prolog context compiler and moves direct mode onto the bounded runtime direct agent loop, per the operator direction to fully use Prolog-RLM for all Agent Zero context and IO (first slice; see #91).

Changes

  • Tool (plugins/_prolog_rlm/tools/prolog_rlm.py): direct and complete now compile the live Agent Zero context through the runtime's context_compile surface first. complete merges the compiled projection with the caller's explicit context. When the context compiler is not enabled the tool keeps the legacy arguments; a rejected context is an explicit failure, never a silent skip.
  • Core-loop proxy (plugins/_prolog_rlm/helpers/loop.py): every routed turn (including direct) compiles a bounded unit request (permanent system unit + prior messages as resources) instead of flattening history into opaque text. direct mode dispatches through the runtime with max_recursion_depth: 1 (symbolic keeps 1, symbolic-recursive 3).
  • Runtime worker (plugins/_prolog_rlm/prolog/runtime_worker.pl): direct dispatch now runs rlm:rlm_direct/4 — the bounded provider-native direct agent loop — over the optional context/1 term, replacing the one-shot llm_query/3 call. context_compile unwraps adapter outcomes and rejects with context_compile_rejected/1. All completion-family outcomes pass through runtime_result/2: success returns the bare result dict, error(...) surfaces as a failed envelope (runtime_fault(...)), never as an ok:true $term-encoded payload.
  • Harness client (helpers/harness/client.py): direct(prompt, context, budget) and a new compile(request) convenience over the closed catalog.
  • Skill: copies the debug-io provider-IO debugging skill from the Prolog-RLM lab into skills/debug-io/ (OpenRouter generation fetch, attribution headers, failure signatures).
  • DOX/prompts updated; new test_prolog_rlm_tool.py; worker contract tests added.

Verification

  • pytest plugins/_prolog_rlm/tests plugins/_prolog_context_compiler/tests — 58 passed (bounded container, pinned runtime source)
  • PlUnit agent_zero_tool_pack_test.pl — 3/3 passed
  • Repository prompt-budget / tool-policy tests — 59 passed
  • Live provider IO through the worker: direct → value: "391" (1 model call, recursion budget active); complete → value: "217"; undersized budget → failed envelope with token_budget_exceeded (fault surface proven)
  • prolog-verify check — pass (facts + observations recorded in .prolog/)
## Summary Routes every `prolog_rlm` network action through the Prolog context compiler and moves direct mode onto the bounded runtime direct agent loop, per the operator direction to fully use Prolog-RLM for all Agent Zero context and IO (first slice; see #91). ## Changes - **Tool** (`plugins/_prolog_rlm/tools/prolog_rlm.py`): `direct` and `complete` now compile the live Agent Zero context through the runtime's `context_compile` surface first. `complete` merges the compiled projection with the caller's explicit context. When the context compiler is not enabled the tool keeps the legacy arguments; a rejected context is an explicit failure, never a silent skip. - **Core-loop proxy** (`plugins/_prolog_rlm/helpers/loop.py`): every routed turn (including `direct`) compiles a bounded unit request (permanent system unit + prior messages as resources) instead of flattening history into opaque text. `direct` mode dispatches through the runtime with `max_recursion_depth: 1` (symbolic keeps 1, symbolic-recursive 3). - **Runtime worker** (`plugins/_prolog_rlm/prolog/runtime_worker.pl`): `direct` dispatch now runs `rlm:rlm_direct/4` — the bounded provider-native direct agent loop — over the optional `context/1` term, replacing the one-shot `llm_query/3` call. `context_compile` unwraps adapter outcomes and rejects with `context_compile_rejected/1`. All completion-family outcomes pass through `runtime_result/2`: success returns the bare result dict, `error(...)` surfaces as a failed envelope (`runtime_fault(...)`), never as an `ok:true` `$term`-encoded payload. - **Harness client** (`helpers/harness/client.py`): `direct(prompt, context, budget)` and a new `compile(request)` convenience over the closed catalog. - **Skill**: copies the `debug-io` provider-IO debugging skill from the Prolog-RLM lab into `skills/debug-io/` (OpenRouter generation fetch, attribution headers, failure signatures). - DOX/prompts updated; new `test_prolog_rlm_tool.py`; worker contract tests added. ## Verification - `pytest plugins/_prolog_rlm/tests plugins/_prolog_context_compiler/tests` — 58 passed (bounded container, pinned runtime source) - PlUnit `agent_zero_tool_pack_test.pl` — 3/3 passed - Repository prompt-budget / tool-policy tests — 59 passed - Live provider IO through the worker: `direct` → `value: "391"` (1 model call, recursion budget active); `complete` → `value: "217"`; undersized budget → failed envelope with `token_budget_exceeded` (fault surface proven) - `prolog-verify check` — pass (facts + observations recorded in `.prolog/`)
- prolog_rlm tool and the core-loop proxy now compile the live Agent Zero
  context through the runtime's context_compile surface before dispatching
- direct mode runs the bounded provider-native direct agent loop
  (rlm_direct/4) with recursion enabled instead of the one-shot llm_query
- worker unwraps ok(...)/error(...) outcomes: faults surface as failed
  envelopes, never as ok:true $term-encoded payloads
- copy the debug-io provider-IO debugging skill from the prolog-rlm lab
nsaspy closed this pull request 2026-09-05 09:44:34 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.