feat: fact_types and mental model exclusion filters for reflect#615
Merged
nicoloboschi merged 13 commits intomainfrom Mar 19, 2026
Merged
feat: fact_types and mental model exclusion filters for reflect#615nicoloboschi merged 13 commits intomainfrom
nicoloboschi merged 13 commits intomainfrom
Conversation
…d mental models Adds three new filtering options to both the reflect endpoint and mental model creation/refresh: - `fact_types`: restrict which fact types (world, experience, observation) are retrieved. Disables irrelevant agent tools entirely (no wasted tokens). - `exclude_mental_models`: skip the search_mental_models tool altogether. - `exclude_mental_model_ids`: exclude specific mental models by ID (merged with the existing self-exclusion logic during mental model refresh). For mental models, options are persisted in the existing `trigger` JSONB column so they are automatically applied on every refresh. The `UpdateMentalModelRequest` already proxies `trigger`, so no extra endpoint changes are needed. Also fixes the test fixture (`pg0_db_url` in conftest.py) to correctly resolve pg0:// URLs and run migrations before tests, which was causing all DB-dependent tests to fail with "relation public.banks does not exist" when HINDSIGHT_API_DATABASE_URL=pg0://uuuu.
- Add enabled_tools guard in reflect agent: if an LLM calls a tool that was excluded (e.g. recall when fact_types=["observation"]), return an error result instead of executing it - Regenerate OpenAPI spec and all SDK clients (Go, Python, TypeScript) to include new fact_types / exclude_mental_models fields
…tools appearing in results
…ids in control plane UI
…s use General tab, clean up labels
…e all mental models
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
fact_typesfilter to restrict which fact types (world,experience,observation) are retrieved during reflect — disabled tools are removed from the agent's tool list entirely (no wasted tokens)exclude_mental_modelsflag to skip thesearch_mental_modelstool altogetherexclude_mental_model_idsto exclude specific mental models by ID (merged with the existing self-exclusion during mental model refresh)/reflectendpoint and mental model create/update — stored in the existingtriggerJSONB column so they apply automatically on every refreshpg0_db_urltest fixture to correctly resolvepg0://URLs and run migrations, which was causing all DB-dependent tests to fail withrelation "public.banks" does not existTest plan
TestMentalModelReflectOptions— trigger field roundtrip for all three new options (create + update)TestReflectFactTypeFiltering— verifies correct tools are excluded from agent loopTestReflectRequestValidation— HTTP 422 for emptyfact_types=[]