Extract is bounded to the ranking: pull → embed → score → extract → score → summarise

The free stages run first and their score bounds the two model stages.
Extract reads only the best extract.per_agent roles of each agent at
extract.min_score or more, then score runs again so the gates read what it
filled; summarise gets a min_score of its own. The cascade steps by
position, since score is in it twice.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-28 15:26:58 +02:00
1 parent c4f2bcc0c9
commit 7db77e83a3
15 files changed
+215 -89

No files matched your search

+15 -7
View File
@@ -8,12 +8,17 @@ refused batch, and failing with a notice when no model is reachable are
`desk.modeltask`'s.
A role is waiting while it is open, has never been answered (`extracted_at IS
NULL`) and has not been given up on. The answer only fills columns that are
still empty: a board's structured field wins over what a model read out of the
prose. See `Store.set_extracted`.
NULL`), has not been given up on, and is in the best `extract.per_agent` of an
enabled agent's ungated scores at `extract.min_score` or more. That bound is
what keeps the cost proportional to the rankings rather than to the boards:
the pull scores every role for free first, then reads the few hundred that
rank, and scores again so the gates see what was filled. A batch built for
named uids finishes what it was dealt whatever their rank. The answer only
fills columns that are still empty: a board's structured field wins over what
a model read out of the prose. See `Store.set_extracted`.
Off by default (`extract.enabled: false`), because on the API backend every
batch is a paid call and ~30k open roles is ~1,500 of them.
batch is a paid call.
"""
from __future__ import annotations
@@ -128,7 +133,8 @@ def _item(role: Role) -> dict[str, Any]:
def build_batch(config: Config, store: Store, limit: int = 20,
uids: Sequence[str] | None = None) -> dict[str, Any]:
return {"instructions": SYSTEM,
"roles": [_item(r) for r in store.extract_waiting(limit, uids)]}
"roles": [_item(r) for r in store.extract_waiting(
limit, config.extract.per_agent, config.extract.min_score, uids)]}
# -------------------------------------------------------------------- answer
@@ -199,9 +205,11 @@ TASK: ModelTask[ExtractResult] = ModelTask(
kind="extract", label="Reading postings for gate fields",
verb="extracting", noun="fields", idle="nothing to extract", items="roles",
settings=lambda config: config.extract,
pending=lambda config, store: store.extract_pending(),
pending=lambda config, store: store.extract_pending(
config.extract.per_agent, config.extract.min_score),
waiting=lambda config, store, limit: [
r.uid for r in store.extract_waiting(limit)],
r.uid for r in store.extract_waiting(
limit, config.extract.per_agent, config.extract.min_score)],
build_batch=build_batch,
system=lambda store: SYSTEM,
schema=SCHEMA,