Skip to content

The decision extractor reads its output cap and tunables from the settings catalog - #181

Merged
zlareb1 merged 7 commits into
mainfrom
fix/decision-extract-gates
Nov 2, 2026
Merged

zlareb1 merged 7 commits into
mainfrom
fix/decision-extract-gates

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

loom decisions extract reads its reply cap from LLM_MAX_TOKENS (decision_extract, overridable through LOOM_LLM_MAX_TOKENS_OVERRIDES), and two new live settings, LOOM_MEMORY_DECISION_EXTRACT_KNOWN_MAX and LOOM_MEMORY_DECISION_EXTRACT_RESTATEMENT_TOP_K, set how many earlier decisions its prompt lists and how many close decision keys its restatement check reads.

Why

The decision extractor kept its model output cap and its tunables as module constants, which three unit gates refuse: test_llm_max_tokens.py (an LLM call's cap is a LLM_MAX_TOKENS entry), test_tunable_constants.py (a tunable number is a setting, or says on its line why it is not one) and test_tests_patch_only_real_settings.py (a test patches only real settings attributes). Each constant, and what it became:

Constant Now Why
server/memory/app/decision_extract.py::_REPLY_TOKENS (4000) LLM_MAX_TOKENS["decision_extract"], read with llm_max_tokens(...) Keyed by the call's llm_stage, like every other LLM call's cap; a deployment can override it live. The cap is read once per call; a reply cut at it reports that cap and names the override.
server/memory/app/decision_extract.py::_RESTATEMENT_TOP_K (20) setting memory_decision_extract_restatement_top_k, LIVE, default 20 (the fetch is capped at 500 rows, so a large value or memory_search_per_key_cap = 0 can read fewer keys) A recall/cost trade-off: how many close decision keys are checked for a confirmed row that already states the candidate. An operator with a large decision namespace may want more.
server/memory/domain/decision_extract.py::MAX_KNOWN_DECISIONS (30) setting memory_decision_extract_known_max, LIVE, default 30 Prompt size against re-run stability: past this many, the remaining decisions of a long document are not listed and may be read under new keys. The cap moves from the pure prompt builder to the app's _known_decisions, which reads the setting.
server/memory/domain/decision_extract.py::CAPTION_MAX_CHARS (80) # not a setting: It defines what a caption is, which decides which sections are never sent to the model; a change is a behaviour change made with its tests.
server/memory/domain/decision_extract.py::OUTCOME_MAX_CHARS (1000) # not a setting: It mirrors DecisionRecordInput.outcome's max_length; test_the_outcome_limit_is_decision_records pins the two together.
server/cli/decisions.py::_MIN_WINDOW_CHARS (500) # not a setting: The floor of the --window-chars flag, which the operator already sets per run.

The two tests that patched the private _llm_provider_source meant to control whether the provider was named by LOOM_LLM_PROVIDER or inferred. They now patch Settings.llm_provider_inferred, the method _fake_chosen reads, so a renamed or removed method fails the patch instead of passing silently.

Scope and risk

The extractor and its tests, the settings catalog and its generated reference, schema and example file, the live-settings and settings-defaults snapshots and the feature page. Defaults equal the old constants, so behaviour is unchanged. No wire change, no stored data, no tenant-scoping change.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. New optional settings LOOM_MEMORY_DECISION_EXTRACT_KNOWN_MAX (30) and LOOM_MEMORY_DECISION_EXTRACT_RESTATEMENT_TOP_K (20), and a new decision_extract key for LOOM_LLM_MAX_TOKENS_OVERRIDES. A build that lacks the key logs and ignores it, as does N-1 with the two new settings, so either set during a rolling upgrade is harmless.
  • Rollback: reverting removes the settings; a build without them logs and ignores them if a settings file or the environment still names them. Nothing stored.

Tests

  • pytest tests/unit/test_decision_extract.py tests/unit/test_llm_max_tokens.py tests/unit/test_tunable_constants.py tests/unit/test_tests_patch_only_real_settings.py tests/unit/test_live_settings.py: pass. New test_the_prompt_lists_at_most_the_configured_known_decisions runs the extractor over three recorded decisions with the setting at 2 and checks the prompt lists two; test_a_deployment_cap_reaches_the_call_and_the_cut_reply_names_it sets a decision_extract override and checks the call and the cut-reply message both use it; the restatement test sets its top_k to 6 and 5 and checks both the fetch and the key walk read it (a confirmed sixth key blocks at 6, not at 5).
  • make format lint typecheck: clean.
  • Full unit suite (pytest tests/unit -q -p no:randomly): 25013 passed, 20 skipped, 1 xfailed.
  • Regenerated with scripts.codegen.settings_reference, settings_schema, settings_example and docs_reference.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code; each constant's use was read before choosing setting or fixed value.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 7 commits November 2, 2026 18:20
…tings catalog

The model call's cap is LLM_MAX_TOKENS["decision_extract"]. How many
earlier decisions the prompt lists and how many close keys the
restatement check reads are live settings. The caption length, the
outcome limit that mirrors decision.record and the --window-chars floor
say why they are not settings. Tests control provider inference through
Settings.llm_provider_inferred instead of a private attribute.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…etch bounds it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the fix/decision-extract-gates branch from ca7664e to 527c174 Compare November 2, 2026 18:21
@zlareb1
zlareb1 merged commit 2fbd0bd into main Nov 2, 2026
21 of 22 checks passed
@zlareb1
zlareb1 deleted the fix/decision-extract-gates branch November 2, 2026 18:42
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
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