Harness direct/complete bypass the context compiler; direct mode skips the bounded runtime loop #202

Open
opened 2026-09-16 10:47:13 +00:00 by nsaspy · 0 comments
Owner

Summary

The Prolog-RLM harness was not using the context compiler on its network paths, and direct mode bypassed the runtime's bounded direct agent loop. Concretely:

  1. The prolog_rlm tool's direct/complete actions never invoked the context compiler — they sent only the caller's raw arguments, so the live Agent Zero context (system prompt sections, tool declarations, working units) never reached the runtime.
  2. The core-loop proxy (PrologRLMModel) only routed symbolic modes through the runtime; direct mode fell straight through to the inner model, and even symbolic turns flattened history into an opaque text blob instead of compiling units.
  3. The vendored runtime worker's direct dispatch used rlm:llm_query/3 (one unbounded model call, no context, no recursion, no tool loop) instead of the runtime's provider-native direct agent loop rlm_direct/4.
  4. The worker serialized ok(...)/error(...) outcomes as ok:true $term-encoded JSON, so runtime faults looked like successes to host callers.

This is the first slice of the operator direction: fully use Prolog-RLM for ALL Agent Zero context and IO — every context projection goes through the Prolog context compiler, and every model IO (direct, symbolic, recursive) goes through the Prolog-owned runtime.

Environment

  • Repo: lost-rob0t/a0-symbolics@fix/context-compiler-unused 7c057880 (base main a81d7d55)
  • prolog-rlm pin (a0-symbolics flake): 2e1264d80d02fecfb9f946e1328caaf1053e7a3b
  • Live verification against local prolog-rlm checkout af9911ae30283e3c9b03000438b463f73d861517
  • Command: pytest plugins/_prolog_rlm/tests plugins/_prolog_context_compiler/tests, PlUnit agent_zero_tool_pack_test.pl, live worker IO via runtime_worker.pl

Repro (pre-fix)

  1. On main, run a direct action through plugins/_prolog_rlm/tools/prolog_rlm.py: arguments contain only {prompt, budget}; no context_compile request is ever emitted.
  2. Inspect plugins/_prolog_rlm/prolog/runtime_worker.pl dispatch for direct: it called rlm:llm_query(Prompt, Options, Outcome) — no context/1 argument accepted, no direct agent loop.
  3. An empty-query complete returned an envelope with ok:true whose result was a $term-encoded error(...) compound.

Expected / Actual

Expected: direct and complete compile the live Agent Zero context through context_compile and run through the bounded runtime (rlm_direct/4 with recursion enabled for direct; rlm_completion/4 for symbolic); faults surface as failed envelopes.

Actual (pre-fix): compiler unused on all harness paths; direct was a single unbounded completion with no context; error(...) outcomes were masked as ok:true.

Evidence (post-fix)

  • Plugin + compiler suites: 58 passed (container, pinned runtime source).
  • PlUnit Agent Zero pack: 3/3 passed.
  • Live provider IO through the worker, inference key from the runtime checkout .env:
    • direct (with context, budget max_total_tokens:512) → value: "391", usage.model_calls: 1
    • complete (symbolic) → value: "217", trajectory reason "root model answered directly without plan execution"
    • undersized budget → failed envelope runtime_request_error: runtime_fault(... token_budget_exceeded ...) (fault surface verified)
  • Verification gate: .prolog/ facts + prolog-verify check → pass.

Follow-ups toward full Prolog-RLM context/IO ownership

  • Route the main-loop tool-execution IO through the runtime's trusted tool-host surface (agent_zero_tool_registry_import/4) so direct-mode tool calls execute inside the Prolog runtime instead of bypassing it.
  • Feed every context projection (system prompt, DOX, history) through context_compile so Prolog owns selection in all lanes, including the working-context extension path.
  • Emit runtime token-ledger/usage evidence into the chat UI policy control for observability.
## Summary The Prolog-RLM harness was not using the context compiler on its network paths, and direct mode bypassed the runtime's bounded direct agent loop. Concretely: 1. The `prolog_rlm` tool's `direct`/`complete` actions never invoked the context compiler — they sent only the caller's raw arguments, so the live Agent Zero context (system prompt sections, tool declarations, working units) never reached the runtime. 2. The core-loop proxy (`PrologRLMModel`) only routed `symbolic` modes through the runtime; `direct` mode fell straight through to the inner model, and even symbolic turns flattened history into an opaque text blob instead of compiling units. 3. The vendored runtime worker's `direct` dispatch used `rlm:llm_query/3` (one unbounded model call, no context, no recursion, no tool loop) instead of the runtime's provider-native direct agent loop `rlm_direct/4`. 4. The worker serialized `ok(...)`/`error(...)` outcomes as `ok:true` `$term`-encoded JSON, so runtime faults looked like successes to host callers. This is the first slice of the operator direction: **fully use Prolog-RLM for ALL Agent Zero context and IO** — every context projection goes through the Prolog context compiler, and every model IO (direct, symbolic, recursive) goes through the Prolog-owned runtime. ## Environment - Repo: lost-rob0t/a0-symbolics@fix/context-compiler-unused 7c057880 (base `main` a81d7d55) - prolog-rlm pin (a0-symbolics flake): 2e1264d80d02fecfb9f946e1328caaf1053e7a3b - Live verification against local prolog-rlm checkout af9911ae30283e3c9b03000438b463f73d861517 - Command: `pytest plugins/_prolog_rlm/tests plugins/_prolog_context_compiler/tests`, PlUnit `agent_zero_tool_pack_test.pl`, live worker IO via `runtime_worker.pl` ## Repro (pre-fix) 1. On `main`, run a `direct` action through `plugins/_prolog_rlm/tools/prolog_rlm.py`: arguments contain only `{prompt, budget}`; no `context_compile` request is ever emitted. 2. Inspect `plugins/_prolog_rlm/prolog/runtime_worker.pl` dispatch for `direct`: it called `rlm:llm_query(Prompt, Options, Outcome)` — no `context/1` argument accepted, no direct agent loop. 3. An empty-query `complete` returned an envelope with `ok:true` whose result was a `$term`-encoded `error(...)` compound. ## Expected / Actual Expected: `direct` and `complete` compile the live Agent Zero context through `context_compile` and run through the bounded runtime (`rlm_direct/4` with recursion enabled for direct; `rlm_completion/4` for symbolic); faults surface as failed envelopes. Actual (pre-fix): compiler unused on all harness paths; `direct` was a single unbounded completion with no context; `error(...)` outcomes were masked as `ok:true`. ## Evidence (post-fix) - Plugin + compiler suites: 58 passed (container, pinned runtime source). - PlUnit Agent Zero pack: 3/3 passed. - Live provider IO through the worker, inference key from the runtime checkout `.env`: - `direct` (with context, budget `max_total_tokens:512`) → `value: "391"`, `usage.model_calls: 1` - `complete` (symbolic) → `value: "217"`, trajectory reason "root model answered directly without plan execution" - undersized budget → failed envelope `runtime_request_error: runtime_fault(... token_budget_exceeded ...)` (fault surface verified) - Verification gate: `.prolog/` facts + `prolog-verify check` → pass. ## Follow-ups toward full Prolog-RLM context/IO ownership - Route the main-loop tool-execution IO through the runtime's trusted tool-host surface (`agent_zero_tool_registry_import/4`) so direct-mode tool calls execute inside the Prolog runtime instead of bypassing it. - Feed every context projection (system prompt, DOX, history) through `context_compile` so Prolog owns selection in all lanes, including the working-context extension path. - Emit runtime token-ledger/usage evidence into the chat UI policy control for observability.
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/a0-symbolics#202
No description provided.