feat(max): add keyword search across taxonomy properties - #76427
Draft
posthog[bot] wants to merge 1 commit into
Draft
feat(max): add keyword search across taxonomy properties#76427posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
Add a `search_properties` query kind to the taxonomy tools so Max can search property names and descriptions by keyword across persons, sessions, groups, and events in one call, instead of guessing an entity and dumping its whole property list. Also fixes an inconsistency where the person branch of `retrieve_entity_properties` had no `max_properties` slice (unlike the group branch), and neither branch told the model when its list was truncated - so a property past the cutoff looked like it didn't exist. Both branches now truncate consistently and note it when they do. Updates the give-up message shown after the iteration limit is hit to distinguish "I looked and didn't find it" from a generic "be more specific", and suggests concrete next steps (exact name, related filter value, existing cohort, or instrumentation). Generated-By: PostHog Code Task-Id: 72f373b9-e2f0-4dc8-8ed3-9a888f47f915
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
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.
Problem
event_properties,entity_properties, etc.) - there's no way to search for a concept.retrieve_entity_properties's person branch had nomax_propertiesslice (unlike the group branch), and neither branch told the model when the list was cut off - so a property past the cutoff looked like it didn't exist rather than "there's more, go look for it".Changes
search_propertiesquery kind/tool that matches a keyword against property names and (where available) user-authored descriptions across persons, sessions, groups, and events in a single call. Wired into all three surfaces that expose taxonomy tools:read_taxonomyMCP-style tool used directly by Max (ee/hogai/tools/read_taxonomy/)ee/hogai/chat_agent/query_planner/)ee/hogai/chat_agent/taxonomy/)retrieve_entity_propertiesto slice consistently for person and group entities, and append a note pointing atsearch_propertieswhen the list was truncated.search_propertiesfirst, then ask for the exact name, a related filter value, an existing cohort, or confirmation the concept isn't instrumented - instead of a generic "be more specific".How did you test this code?
Added test coverage (no DB available in this sandbox to run pytest, so verified with
ruff check,ruff format --check,hogli ci:preflight --fix, and a full-repomypypass - all clean):ee/hogai/chat_agent/query_planner/test/test_toolkit.py: truncation marker appears for both person and group entities when over the limit and not when under it;search_propertiesmatches by name across person/group/event and by stored description; no-match returns the guided message.ee/hogai/tools/read_taxonomy/test/test_tool.py:execute_taxonomy_querydispatches the newsearch_propertieskind to the toolkit (guards the match/case wiring).ee/hogai/chat_agent/taxonomy/test/test_toolkit.py: added asearch_propertiescase to the existingtest_handle_toolsparameterization, guarding the batching/dispatch wiring in the async toolkit.Automatic notifications
Docs update
N/A - internal AI assistant tool behavior, no user-facing docs to update.
🤖 Agent context
Autonomy: Fully autonomous
I (Claude, via PostHog's coding agent) investigated an inbox report describing two independent customer sessions where Max failed to find a property the user had in mind (a "streaks" segmentation and an "internal user" filter), because the taxonomy tools only support enumerate-by-name lookups. I checked for existing overlapping work first (
gh pr list/gh issue listacrossread_taxonomy,retrieve_entity_properties, taxonomy tools) and found none targeting this - only unrelated fixes (event-window disclosure, retry logic) touching the same files.Decisions along the way:
read_taxonomyMCP tool, the query-planner sub-agent, and the taxonomy sub-agent), since the report called out bothread_taxonomyand the sub-agent toolkit as needing the fix, and they turned out to be three separate (non-shared) implementations.PropertyDefinition/EnterprisePropertyDefinitionqueries rather than adding new infrastructure (embeddings, fuzzy matching), to stay contained and consistent with how descriptions are already surfaced elsewhere.Created with PostHog Desktop from this inbox report