docs(SCOPE): intent gate types the response; tool_call is a loop output

Emili's correction: the gate annotates the goal with the expected response type (answer/tool_call/chat/meta/plan_only); it never chooses paths, tools or experts. Deciding the next step is reasoning and goes through the loop (subquestions, ROUTE, experts, prover). tool_schema rows in, tool_call row out with provenance, tool_result as user-side observation, iterate like ReAct with evidenced steps. GAPS.md GAP-11/12 corrected in place.
This commit is contained in:
2026-10-13 23:17:40 +02:00
parent 6733cb660e
commit e8fa401597
2 changed files with 86 additions and 77 deletions
+20 -12
View File
@@ -180,23 +180,31 @@ only handles `answer`-shaped requests.
**Bites:** positioned as a harness model, floop would decompose "what's the weather in **Bites:** positioned as a harness model, floop would decompose "what's the weather in
Barcelona?" (needing the harness's weather tool) into retrieval subquestions instead of Barcelona?" (needing the harness's weather tool) into retrieval subquestions instead of
emitting a tool call — unusable as an agent LLM. emitting a tool call — unusable as an agent LLM.
**Resolution (design in SCOPE.md):** a top-level intent gate (one LLM judgement + fixed-code **Resolution (design in SCOPE.md) — CORRECTED by Emili (2026-10-13):** the intent gate
validation; the LLM proposes, code disposes — same philosophy as ROUTE): `answer | tool_call | TYPES the response expected by the user/harness (`answer | tool_call | chat | meta |
chat | meta | plan_only(future)`. Misroute matrix declared; ambiguous → user (expert of last plan_only(future)`), like answer_type on GoalSchema — it does NOT choose the processing
resort). Q&A becomes one use case of the interface contract. path and does NOT pick tools or experts. Deciding the next step (call a tool, ask an
expert, stop) is reasoning, and all reasoning goes through the loop: subquestions, ROUTE,
experts, prover-gated stopping. A wrong response type degrades as a type mismatch on
output arrival (refusal/replan), never as skipped reasoning.
**Patch:** SCOPE.md §1-§2 (new doc); README.md definition; PIPELINE.md §1 note. **Patch:** SCOPE.md §1-§2 (new doc); README.md definition; PIPELINE.md §1 note.
### GAP-12 — tool_call flow and `tool_result` semantics ### GAP-12 — tool_call flow and `tool_result` semantics
Follows GAP-11: nothing defines how a harness's tool list flows through floop, nor what a Follows GAP-11: nothing defines how a harness's tool list flows through floop, nor what a
tool result is epistemically. tool result is epistemically.
**Resolution (SCOPE.md §3):** harness sends OpenAI-style tools with the request; an LLM call **Resolution (SCOPE.md §3) — CORRECTED by Emili (2026-10-13):** tool_call is an OUTPUT of
proposes (tool, arguments); **code validates** against the tool's JSON schema + tool list the loop, not an alternative path to it. Tool list + JSON schemas enter as typed evidence
membership; the tool executes outside the LLM (or the tool_call object is returned to the (`tool_schema` rows); "which tool satisfies this?", "what arguments?", "is the observation
harness — same contract as any LLM). The result enters the evidence table as a **`tool_result` enough?" are ordinary subquestions routed to experts (logic over schemas, analytic/numeric
row: an observation with provenance** (tool name, args, ts, payload) — epistemically like for argument values, knowledge for world facts) — no LLM shortcut decides a tool directly.
UserReply rows: user-side facts about what happened, never "verified" claims, no containment The loop emits a typed tool_call row (tool, args) with provenance over the schema/evidence
check (that gate is for source-document quotes), never silently retracted; conflicts → user. rows that justify it; the tool executes outside the LLM (harness-side when floop serves as
**Patch:** SCOPE.md §3; PIPELINE.md §5 (add row type + provenance law note). the model); its result enters the table as a **`tool_result` row: an observation with
provenance** (tool name, args, ts, payload) — epistemically like UserReply rows: user-side
facts about what happened, never "verified" claims, no containment check (that gate is for
source-document quotes), never silently retracted; conflicts → user. Then the loop iterates
on the new observation (ReAct with typed, evidenced steps; stop = prover).
**Patch:** SCOPE.md §3; PIPELINE.md §5 (add row types + provenance law note).
### GAP-13 — serving is invisible: no per-call progress stream, no run log ### GAP-13 — serving is invisible: no per-call progress stream, no run log
Emili (2026-10-13): running from CLI shows only the final summary; LLM calls can be long — Emili (2026-10-13): running from CLI shows only the final summary; LLM calls can be long —
+66 -65
View File
@@ -1,9 +1,8 @@
# SCOPE.md — floop beyond Q&A # SCOPE.md — floop beyond Q&A
Status: DESIGN for review — no code yet. Extends PIPELINE.md/README; three additions from Status: DESIGN for review — no code yet. Three additions from Emili's review of 2026-10-13
Emili's review of 2026-10-13: (1) floop's goal is a drop-in LLM replacement, Q&A is one use (floop as a drop-in LLM, CLI streaming, offline meta level), **corrected the same day**:
case; (2) the CLI must stream progress; (3) an offline meta-level that learns from floop's the intent gate types the response; it never bypasses the loop (§2).
own runs.
## 1. Reframing: floop as a drop-in LLM ## 1. Reframing: floop as a drop-in LLM
@@ -11,90 +10,92 @@ floop exposes an **LLM-like interface**: `messages + system + tools in → text
out`, OpenAI-compatible. A Hermes agent (or any harness) should be able to point its model out`, OpenAI-compatible. A Hermes agent (or any harness) should be able to point its model
provider at floop and behave exactly as before. Everything inside is the fractal loop — LLM provider at floop and behave exactly as before. Everything inside is the fractal loop — LLM
calls that translate/propose, typed evidence, engines that decide, a prover that gates calls that translate/propose, typed evidence, engines that decide, a prover that gates
stopping. "Answer questions" is what the loop does for one request type; the contract with stopping. "Answer questions" is what the loop does for one response type; the contract with
the harness is broader. the harness is broader.
## 2. The intent layer (new top-level gate) ## 2. The intent layer — a response-type gate, not a path switch
Every harness request first passes an intent classification — one LLM judgement (same style Every harness request first passes an intent classification — one LLM judgement + fixed-code
as ROUTE) + fixed-code validation — over a closed catalogue: validation — that declares **what kind of response is expected**: `answer | tool_call |
chat | meta | plan_only` (future). That is ALL the gate does.
- `answer` — decompose → experts → proven answer (the current FLOOP loop) What the gate does NOT do (Emili's correction, 2026-10-13): choose the processing path, pick
- `tool_call` — the request maps to an external tool from the harness's tool list tools, or decide which experts run. Deciding the next step — call this tool, ask that
- `chat` — conversation management (greetings, clarification, small talk): no decomposition, expert, stop here — is **reasoning**, and all reasoning goes through the loop: subquestions,
no engines; direct synthesis, honestly marked like everything else ROUTE per question, experts as attendants, prover-gated stopping. The gate only annotates
- `meta` — floop on itself: self-analysis, KG maintenance (§5) the goal with the expected response type (GoalSchema.response_type), the same way
- `plan_only` (future) — return the plan without executing, for harnesses that want to drive answer_type is declared and then tightened by evidence.
Validation is code: a `tool_call` must name a tool present in the harness-provided list, and `chat` and `meta` are goal types too: the loop still runs and simply finds them trivially
its arguments must validate against that tool's JSON schema; invalid classification falls derivable (a greeting needs no decomposition), or — for `meta` — schedules floop's own
back to `answer` or escalates to the user (the expert of last resort). The misroute matrix: maintenance (§5).
answer-routed requests that needed tools waste budget but stay honest; tool_call-routed
requests that fail fail loudly into the failure path (re-route or user).
## 3. The tool_call flow ## 3. tool_call is an OUTPUT of the loop, not an alternative to it
1. The harness sends `tools` (OpenAI-style) with the request. A harness runs a ReAct loop: observe tool results, decide the next action, repeat. floop
2. An LLM call proposes `(tool, arguments)`; fixed code validates against the tool schema and serves that loop with the same machinery it uses for questions:
the tool list.
3. The tool executes **outside the LLM** (engine discipline: no LLM inside a tool run); if
floop runs embedded as a harness model, it returns the `tool_call` object and the harness
executes — same contract as any LLM.
4. The result enters the evidence table as a `tool_result` row: an **observation with
provenance** (tool name, arguments, timestamp, raw result or summary). Epistemic treatment
identical to user replies: user-side facts about what happened, not verified claims; no
containment check (that gate is for source-document quotes); never silently retracted —
conflicts go back to the user.
## 4. progress streaming + run logs (CLI) 1. The harness's tool list + JSON schemas enter as typed evidence (`tool_schema` rows).
2. "Which tool can satisfy this?", "what arguments does it need?", "is the last observation
enough to answer?" are **ordinary subquestions**, routed to experts like any other:
logic reasons over schemas, analytic/numeric compute argument values, knowledge supplies
world facts. No LLM shortcut decides a tool directly.
3. The loop's OUTPUT can be a `tool_call`: a typed row (tool, args) whose provenance cites
the schema rows and evidence that justify it. Fixed code validates it against the tool's
schema before emission — the LLM proposes, code disposes.
4. The tool executes **outside the LLM** (harness-side when floop serves as the model —
same contract as any LLM). Its observation enters the table as a `tool_result` row: a
user-side fact with provenance (tool name, args, ts, payload) — like UserReply rows,
never "verified", never silently retracted; conflicts go to the user.
5. Then the loop iterates on the new observation: re-decide — another tool, an expert, or
stop (prover). Every step of the ReAct chain is evidenced and auditable: "thought" is
replaced by computation, "observation" is typed before it enters the state.
Design: an event stream is produced on every run — one format, two sinks. Stopping for a tool-call goal: the prover's derivability instantiates as "the evidence
supports a concrete (tool, args)" — same formal shape, different predicate. Misroutes
degrade cheaply: a wrong response type is a type mismatch on output arrival — the same
refusal/replan path any type mismatch takes; the reasoning was never skipped.
Events: `call` (stage starting: INIT | ROUTE | EXPERT | MISSING | ANSWER | ENGINE, with input ## 4. progress streaming + run logs (CLI) — IMPLEMENTED (CLI part)
summary), `output` (raw LLM output or engine payload), `state` (evidence row appended,
question status change, budget tick), `final` (the report).
Sinks: Design: an event stream is produced on every run — one format, two channels.
- **Always**: `runs/<ts>-<slug>/run.log`, written with explicit flush after every event, so
`tail -f floop/code/runs/<latest>/run.log` works from another terminal.
- **`--verbose` flag**: tee the same events to the screen with `print(..., flush=True)`.
- (later, same events) the OpenAI-compatible endpoint's streaming mode: SSE-style events for
external consumers (§2-bis of the interface contract).
## 5. The meta-level: floop learns from its own runs (offline, future) - **Always**: `runs/<ts>-<slug>/run.log` with explicit flush (tail -f-able): timestamps,
budget ticks, raw payloads, all technical detail.
- **`--verbose`**: the **thinking** subset prints to the screen (flushed, `[T]` lines, `>`
depth prefixes). Thinking is the future user-facing "thinking" output of floop-as-LLM;
log ⊇ thinking, and they will diverge.
- (later, same events) the endpoint's streaming mode: SSE-style events for external
consumers.
## 5. The meta level: floop learns from its own runs (offline, future)
After answering, floop analyses itself — **as a scheduled task, not inside the serving After answering, floop analyses itself — **as a scheduled task, not inside the serving
loop**. Design shape: loop**. Design shape:
- **Self-analysis run** (a dspy signature, e.g. `SelfAnalysis`): input = a completed run's - **Self-analysis run** (a dspy signature, e.g. `SelfAnalysis`): input = a completed run's
report + question stack + evidence table (+ tool results, + which steps failed); output = report + question stack + evidence table (+ tool results, + which steps failed); output =
structured critique — where decomposition over-split or under-split, where routing misfired, structured critique — where decomposition over-split or under-split, where routing
where the check layer should have caught something, budget spent well or wasted, and what misfired, where the check layer should have caught something, budget spent well or wasted.
the lesson is. The critique is appended to the run dir and to a **lessons bank** The critique is appended to the run dir and to a **lessons bank** (`runs/lessons.md`).
(`runs/lessons.md`), and its structured fields are what the v2 router will train on. - **Knowledge growth**: the same scheduled task runs the knowledge gather offline — filling
- **Knowledge growth**: the same scheduled task may run knowledge-expert gather offline — KG gaps observed in past runs (entities repeatedly unresolved → fetch proactively).
filling KG gaps observed in past runs (entities repeatedly unresolved → fetch their - **Prompt improvement (dspy-native)**: our prompts are Signature docstrings; dspy
Wikipedia entry proactively). optimizers (BootstrapFewShot now, MIPROv2-class later) compile improved prompts from the
- **Prompt improvement (dspy-native)**: our prompts are Signature docstrings; dspy's lessons bank + critiques — trainset = critiques with quality labels, metric = post-hoc
optimizers (BootstrapFewShot now, MIPROv2-class later) can compile improved prompts from evaluator agreement. Adopted only when measured.
the lessons bank + critiques — trainset = critiques with quality labels, metric = a - **Fine-tuning path (later)**: logged trajectories become SFT data for the models we call.
post-hoc evaluator's agreement. Adopted only when measured (never silently swap prompts).
- **Fine-tuning path (later)**: logged trajectories become SFT data for the models we call —
floop's honest logs are the dataset.
Connection to the plan: v2's learned router (PIPELINE §7) needs exactly these logged Connection to the plan: v2's learned router (PIPELINE §7) needs exactly these logged
trajectories + critiques as training data; the meta-level is how they get produced. trajectories + critiques as training data; the meta-level is how they get produced.
## 6. Doc ripple (what else changes when this lands) ## 6. Doc ripple
- README: reposition the definition ("floop is a drop-in LLM replacement with provable tool - README: definition already repositioned; PIPELINE.md still to note the response-type gate
behaviour; Q&A is the first use case"). and the `tool_schema` / `tool_result` row types (§5).
- PIPELINE.md: add the intent gate as §3-bis-antecessor (a top-level step before INIT) and - GAPS.md: GAP-11/12 carry the 2026-10-13 correction; GAP-13 (streaming) CLI part done.
`tool_result` as a new evidence-row type in §5.
- GAPS.md: GAP-11 (intent layer), GAP-12 (event stream + run logs), GAP-13 (meta-level +
lessons bank) — entries with what/where-bites/resolution.
## 7. Explicitly NOT now ## 7. Explicitly NOT now
No code for the gate, the endpoint, the event stream, or self-analysis — this document only. No code for the gate, the endpoint, or self-analysis — this document only. Everything here
Everything here is future work recorded while the project is being defined, per Emili. is future work recorded while the project is being defined.