feat(api): add recall controls to mental model trigger#1048
Merged
nicoloboschi merged 9 commits intomainfrom Apr 14, 2026
Merged
feat(api): add recall controls to mental model trigger#1048nicoloboschi merged 9 commits intomainfrom
nicoloboschi merged 9 commits intomainfrom
Conversation
Internal recall during mental model refresh used to hardcode include_chunks=True with fixed token budgets, wasting prompt budget on chunks that some refreshes don't need. Adds three knobs exposed both as hierarchical config (env -> tenant -> bank) and as per-mental-model overrides on the trigger JSONB field: - recall_include_chunks / trigger.include_chunks - recall_max_tokens / trigger.recall_max_tokens - recall_chunks_max_tokens / trigger.recall_chunks_max_tokens Trigger value (when set) wins over bank/global config. Both refresh paths (task handler and synchronous refresh_mental_model) forward the overrides into reflect_async.
…logs Adds form fields under the Options tab for the three new trigger overrides (include_chunks, recall_max_tokens, recall_chunks_max_tokens) in both the create and update mental model dialogs. Empty/Default means inherit the bank/global config.
92bc28c to
b180706
Compare
3 tasks
ToxicFill
approved these changes
Apr 14, 2026
mrkhachaturov
added a commit
to mrkhachaturov/hindsight
that referenced
this pull request
Apr 14, 2026
hindsight-docs/static/bank-template-schema.json is hand-edited. Nothing regenerates it and nothing checks it. Three PRs have changed BankTemplateManifest since it was last touched: vectorize-io#902 flipped entity_labels from list[str] to list[dict[str, Any]], vectorize-io#1044 added ten BankTemplateConfig fields, vectorize-io#1048 added three MentalModelTrigger fields. None of the bundled templates use the new fields, so Ajv in check-templates.mjs still passes. A template that uses the dict-shaped label format fails with 'should be string' on every label. Regenerate from BankTemplateManifest.model_json_schema() and hook the generator into verify-generated-files alongside generate-openapi and generate-clients.
mrkhachaturov
added a commit
to mrkhachaturov/hindsight
that referenced
this pull request
Apr 14, 2026
hindsight-docs/static/bank-template-schema.json is hand-edited. Nothing regenerates it and nothing checks it. Three PRs have changed BankTemplateManifest since it was last touched: vectorize-io#902 flipped entity_labels from list[str] to list[dict[str, Any]], vectorize-io#1044 added ten BankTemplateConfig fields, vectorize-io#1048 added three MentalModelTrigger fields. None of the bundled templates use the new fields, so Ajv in check-templates.mjs still passes. A template that uses the dict-shaped label format fails with 'should be string' on every label. Regenerate from BankTemplateManifest.model_json_schema() and hook the generator into verify-generated-files alongside generate-openapi and generate-clients.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
triggerJSONB field:recall_include_chunks/trigger.include_chunksrecall_max_tokens/trigger.recall_max_tokensrecall_chunks_max_tokens/trigger.recall_chunks_max_tokenstool_recallno longer hardcodesinclude_chunks=True. Both refresh code paths (task handler and synchronousrefresh_mental_model) forward the overrides intoreflect_async, which resolves trigger → bank config → env default.Test plan
cd hindsight-api-slim && uv run pytest tests/test_recall_config.py -v(12/12 pass — covers tool_recall param, config plumbing, Pydantic acceptance, and end-to-end trigger → reflect_async wiring for both refresh paths)./scripts/hooks/lint.shcd hindsight-api-slim && uv run ruff check . && uv run ty check hindsight_api/trigger = {"include_chunks": false, "recall_max_tokens": 512}and verify a refresh runs without chunks and within the smaller token budget