Skip to content

feat(api): add recall controls to mental model trigger#1048

Merged
nicoloboschi merged 9 commits intomainfrom
feat/mental-model-recall-controls
Apr 14, 2026
Merged

feat(api): add recall controls to mental model trigger#1048
nicoloboschi merged 9 commits intomainfrom
feat/mental-model-recall-controls

Conversation

@nicoloboschi
Copy link
Copy Markdown
Collaborator

Summary

  • Adds three knobs that control the internal recall used during mental model refresh, exposed both as hierarchical config (env → tenant → bank) and as per-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
  • tool_recall no longer hardcodes include_chunks=True. Both refresh code paths (task handler and synchronous refresh_mental_model) forward the overrides into reflect_async, which resolves trigger → bank config → env default.
  • Regenerated OpenAPI + Python/TypeScript/Go SDK clients; updated control plane TS trigger types; documented the env vars.

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.sh
  • cd hindsight-api-slim && uv run ruff check . && uv run ty check hindsight_api/
  • Manual: create a mental model with trigger = {"include_chunks": false, "recall_max_tokens": 512} and verify a refresh runs without chunks and within the smaller token budget

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.
@nicoloboschi nicoloboschi force-pushed the feat/mental-model-recall-controls branch from 92bc28c to b180706 Compare April 14, 2026 10:10
@nicoloboschi nicoloboschi merged commit f2fc8f9 into main Apr 14, 2026
102 of 106 checks passed
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.
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.

2 participants