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:
@@ -180,23 +180,31 @@ only handles `answer`-shaped requests.
|
||||
**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
|
||||
emitting a tool call — unusable as an agent LLM.
|
||||
**Resolution (design in SCOPE.md):** a top-level intent gate (one LLM judgement + fixed-code
|
||||
validation; the LLM proposes, code disposes — same philosophy as ROUTE): `answer | tool_call |
|
||||
chat | meta | plan_only(future)`. Misroute matrix declared; ambiguous → user (expert of last
|
||||
resort). Q&A becomes one use case of the interface contract.
|
||||
**Resolution (design in SCOPE.md) — CORRECTED by Emili (2026-10-13):** the intent gate
|
||||
TYPES the response expected by the user/harness (`answer | tool_call | chat | meta |
|
||||
plan_only(future)`), like answer_type on GoalSchema — it does NOT choose the processing
|
||||
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.
|
||||
|
||||
### 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
|
||||
tool result is epistemically.
|
||||
**Resolution (SCOPE.md §3):** harness sends OpenAI-style tools with the request; an LLM call
|
||||
proposes (tool, arguments); **code validates** against the tool's JSON schema + tool list
|
||||
membership; the tool executes outside the LLM (or the tool_call object is returned to the
|
||||
harness — same contract as any LLM). The result enters the evidence 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.
|
||||
**Patch:** SCOPE.md §3; PIPELINE.md §5 (add row type + provenance law note).
|
||||
**Resolution (SCOPE.md §3) — CORRECTED by Emili (2026-10-13):** tool_call is an OUTPUT of
|
||||
the loop, not an alternative path to it. Tool list + JSON schemas enter as typed evidence
|
||||
(`tool_schema` rows); "which tool satisfies this?", "what arguments?", "is the observation
|
||||
enough?" are ordinary subquestions routed to experts (logic over schemas, analytic/numeric
|
||||
for argument values, knowledge for world facts) — no LLM shortcut decides a tool directly.
|
||||
The loop emits a typed tool_call row (tool, args) with provenance over the schema/evidence
|
||||
rows that justify it; the tool executes outside the LLM (harness-side when floop serves as
|
||||
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
|
||||
Emili (2026-10-13): running from CLI shows only the final summary; LLM calls can be long —
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# SCOPE.md — floop beyond Q&A
|
||||
|
||||
Status: DESIGN for review — no code yet. Extends PIPELINE.md/README; three additions from
|
||||
Emili's review of 2026-10-13: (1) floop's goal is a drop-in LLM replacement, Q&A is one use
|
||||
case; (2) the CLI must stream progress; (3) an offline meta-level that learns from floop's
|
||||
own runs.
|
||||
Status: DESIGN for review — no code yet. Three additions from Emili's review of 2026-10-13
|
||||
(floop as a drop-in LLM, CLI streaming, offline meta level), **corrected the same day**:
|
||||
the intent gate types the response; it never bypasses the loop (§2).
|
||||
|
||||
## 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
|
||||
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
|
||||
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.
|
||||
|
||||
## 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
|
||||
as ROUTE) + fixed-code validation — over a closed catalogue:
|
||||
Every harness request first passes an intent classification — one LLM judgement + fixed-code
|
||||
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)
|
||||
- `tool_call` — the request maps to an external tool from the harness's tool list
|
||||
- `chat` — conversation management (greetings, clarification, small talk): no decomposition,
|
||||
no engines; direct synthesis, honestly marked like everything else
|
||||
- `meta` — floop on itself: self-analysis, KG maintenance (§5)
|
||||
- `plan_only` (future) — return the plan without executing, for harnesses that want to drive
|
||||
What the gate does NOT do (Emili's correction, 2026-10-13): choose the processing path, pick
|
||||
tools, or decide which experts run. Deciding the next step — call this tool, ask that
|
||||
expert, stop here — is **reasoning**, and all reasoning goes through the loop: subquestions,
|
||||
ROUTE per question, experts as attendants, prover-gated stopping. The gate only annotates
|
||||
the goal with the expected response type (GoalSchema.response_type), the same way
|
||||
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
|
||||
its arguments must validate against that tool's JSON schema; invalid classification falls
|
||||
back to `answer` or escalates to the user (the expert of last resort). The misroute matrix:
|
||||
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).
|
||||
`chat` and `meta` are goal types too: the loop still runs and simply finds them trivially
|
||||
derivable (a greeting needs no decomposition), or — for `meta` — schedules floop's own
|
||||
maintenance (§5).
|
||||
|
||||
## 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.
|
||||
2. An LLM call proposes `(tool, arguments)`; fixed code validates against the tool schema and
|
||||
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.
|
||||
A harness runs a ReAct loop: observe tool results, decide the next action, repeat. floop
|
||||
serves that loop with the same machinery it uses for questions:
|
||||
|
||||
## 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
|
||||
summary), `output` (raw LLM output or engine payload), `state` (evidence row appended,
|
||||
question status change, budget tick), `final` (the report).
|
||||
## 4. progress streaming + run logs (CLI) — IMPLEMENTED (CLI part)
|
||||
|
||||
Sinks:
|
||||
- **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).
|
||||
Design: an event stream is produced on every run — one format, two channels.
|
||||
|
||||
## 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
|
||||
loop**. Design shape:
|
||||
|
||||
- **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 =
|
||||
structured critique — where decomposition over-split or under-split, where routing misfired,
|
||||
where the check layer should have caught something, budget spent well or wasted, and what
|
||||
the lesson is. The critique is appended to the run dir and to a **lessons bank**
|
||||
(`runs/lessons.md`), and its structured fields are what the v2 router will train on.
|
||||
- **Knowledge growth**: the same scheduled task may run knowledge-expert gather offline —
|
||||
filling KG gaps observed in past runs (entities repeatedly unresolved → fetch their
|
||||
Wikipedia entry proactively).
|
||||
- **Prompt improvement (dspy-native)**: our prompts are Signature docstrings; dspy's
|
||||
optimizers (BootstrapFewShot now, MIPROv2-class later) can compile improved prompts from
|
||||
the lessons bank + critiques — trainset = critiques with quality labels, metric = a
|
||||
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.
|
||||
structured critique — where decomposition over-split or under-split, where routing
|
||||
misfired, where the check layer should have caught something, budget spent well or wasted.
|
||||
The critique is appended to the run dir and to a **lessons bank** (`runs/lessons.md`).
|
||||
- **Knowledge growth**: the same scheduled task runs the knowledge gather offline — filling
|
||||
KG gaps observed in past runs (entities repeatedly unresolved → fetch proactively).
|
||||
- **Prompt improvement (dspy-native)**: our prompts are Signature docstrings; dspy
|
||||
optimizers (BootstrapFewShot now, MIPROv2-class later) compile improved prompts from the
|
||||
lessons bank + critiques — trainset = critiques with quality labels, metric = post-hoc
|
||||
evaluator agreement. Adopted only when measured.
|
||||
- **Fine-tuning path (later)**: logged trajectories become SFT data for the models we call.
|
||||
|
||||
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.
|
||||
|
||||
## 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
|
||||
behaviour; Q&A is the first use case").
|
||||
- PIPELINE.md: add the intent gate as §3-bis-antecessor (a top-level step before INIT) and
|
||||
`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.
|
||||
- README: definition already repositioned; PIPELINE.md still to note the response-type gate
|
||||
and the `tool_schema` / `tool_result` row types (§5).
|
||||
- GAPS.md: GAP-11/12 carry the 2026-10-13 correction; GAP-13 (streaming) CLI part done.
|
||||
|
||||
## 7. Explicitly NOT now
|
||||
|
||||
No code for the gate, the endpoint, the event stream, or self-analysis — this document only.
|
||||
Everything here is future work recorded while the project is being defined, per Emili.
|
||||
No code for the gate, the endpoint, or self-analysis — this document only. Everything here
|
||||
is future work recorded while the project is being defined.
|
||||
Reference in New Issue
Block a user