Skip to content

feat(wiki): batch related orphan triage into one maintainer call - #20

Merged
dimknaf merged 5 commits into
mainfrom
feat/wiki-triage-cluster
Jun 16, 2026
Merged

feat(wiki): batch related orphan triage into one maintainer call#20
dimknaf merged 5 commits into
mainfrom
feat/wiki-triage-cluster

Conversation

@dimknaf

@dimknaf dimknaf commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

The wiki maintainer triaged orphan entities one at a time — one agent run (recall + graph research) per orphan, so same-subject keywords that share a source fact each repeated the same neighbourhood research. This PR lets the maintainer claim a few related orphan triage jobs together — non-hub keywords that share a source fact, plus that fact's own job — and decide them in a single agent call, one decision per seed.

run_cron and the per-job lifecycle are unchanged: every job still closes with its own status (skip→rejected, attach→done+suggestion, …); a singleton — or the flag off — is a one-seed unit identical to today. Gated by WIKI_TRIAGE_CLUSTER (default on; WIKI_TRIAGE_CLUSTER_MAX / WIKI_TRIAGE_HUB_DEGREE tune it).

Why: materially fewer maintainer LLM calls for the same work — same-subject keywords no longer each re-run the same research.

Validation — A/B vs the one-at-a-time path on the same snapshot

  • Same decisions: identical done/rejected split (823 done; rejected within 1) and the same attach/create/consolidate mix.
  • Near-identical wikis: same top subjects and membership counts.
  • Fewer calls: ~1.6 orphans decided per LLM call.
  • No conflation (the main risk of batching): multi-seed batches decide each seed independently — co-occurring seeds land on different wikis or skip, never lazily fused.

Also exercised on a smaller self-hosted model (Gemma 4 12B): the clustered maintainer produced the same kinds of decisions and wikis, so the batched / structured-output path holds up across model sizes.

Changes

  • braindb/services/wiki_jobs.pyWIKI_TRIAGE_CLUSTER / WIKI_TRIAGE_CLUSTER_MAX / WIKI_TRIAGE_HUB_DEGREE + claim_related_triage
  • braindb/routers/wiki.py — claim-side wiki_maintain + extracted _apply_decision (the existing per-seed resolution, verbatim)
  • braindb/agent/schemas.pyMaintainerClusterItem + MaintainerClusterDecision (reuse MaintainerDecision)
  • braindb/agent/prompts/wiki_maintainer_prompt.md — SEED → SEEDS list; one decision per seed; "co-occurrence is not identity"
  • braindb/agent/tools.py — bind the maintainer final_answer to the cluster schema
  • tests/test_final_answer_rename.py — track the schema rebind
  • braindb/config.py — add the vllm_workstation_gemma12b LLM profile
  • integrations/hermes/braindb/__init__.py — env-configurable Hermes ask-timeout (BRAINDB_ASK_TIMEOUT, default 600s)

Tests

Pure-unit suite green (final_answer/schema, handoff hooks, config profiles, chunking).

dimknaf added 5 commits June 16, 2026 13:28
The maintainer triaged one orphan per LLM call; same-subject keywords sharing a
source fact each repeated the same research. With WIKI_TRIAGE_CLUSTER on (default)
it now claims a few related pending triage jobs together (non-hub keywords sharing
a source fact + that fact's own job) and decides every seed in ONE agent call, one
decision per seed. run_cron and the per-job lifecycle are unchanged: each job still
closes with its own status; a singleton (or flag off) is a 1-seed unit, as before.

Validated against the one-at-a-time path on the same snapshot: identical decision
split and near-identical wikis, at ~1.6 orphans/call (~37% fewer LLM calls), with
multi-seed batches deciding each seed independently (no conflation).
…600s)

_ASK_TIMEOUT is now read from BRAINDB_ASK_TIMEOUT (default 600s, was a
hardcoded 90s) so a slow /agent/query LLM loop doesn't time out and the
ceiling is tunable per deployment.
…ClusterDecision

submit_maintainer now carries MaintainerClusterDecision (a `decisions` list,
one entry per seed) instead of the flat MaintainerDecision, so the tool-schema
assertion is updated to expect `decisions` as the only required field. The
base MaintainerDecision model is unchanged, so the model-direct tests stay.
A self-hosted vLLM profile for Gemma 4 12B (QAT w4a16) served at
host.docker.internal:8012, mirroring the existing vllm_workstation_* profiles.
Select it with LLM_PROFILE=vllm_workstation_gemma12b to run the agent on the
local Gemma model.
@dimknaf
dimknaf merged commit 42a7651 into main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant