Skip to content

feat(max): add keyword search across taxonomy properties - #76427

Draft
posthog[bot] wants to merge 1 commit into
masterfrom
posthog-self-driving/featphai-add-keyword-search-to-60bf1b
Draft

feat(max): add keyword search across taxonomy properties#76427
posthog[bot] wants to merge 1 commit into
masterfrom
posthog-self-driving/featphai-add-keyword-search-to-60bf1b

Conversation

@posthog

@posthog posthog Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Problem

  • Max's taxonomy tools can only enumerate properties by name (event_properties, entity_properties, etc.) - there's no way to search for a concept.
  • A request like "filter out internal users" or "split by streaks" forces Max to guess an entity, dump its whole property list, and eyeball it. With a 10-16 iteration cap on the ReAct loop, this often dead-ends before a match is found.
  • Two related bugs made this worse:
    • retrieve_entity_properties's person branch had no max_properties slice (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".
    • The give-up message after hitting the iteration limit was a generic "could you be more specific", which doesn't distinguish "this isn't tracked" from "I only looked in one place".

Changes

  • Added a search_properties query 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:
    • the read_taxonomy MCP-style tool used directly by Max (ee/hogai/tools/read_taxonomy/)
    • the query-planner ReAct sub-agent used to build trends/funnels/retention (ee/hogai/chat_agent/query_planner/)
    • the taxonomy ReAct sub-agent (ee/hogai/chat_agent/taxonomy/)
  • Fixed retrieve_entity_properties to slice consistently for person and group entities, and append a note pointing at search_properties when the list was truncated.
  • Reworded the iteration-limit give-up message to nudge trying search_properties first, 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-repo mypy pass - 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_properties matches 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_query dispatches the new search_properties kind to the toolkit (guards the match/case wiring).
  • ee/hogai/chat_agent/taxonomy/test/test_toolkit.py: added a search_properties case to the existing test_handle_tools parameterization, guarding the batching/dispatch wiring in the async toolkit.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

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 list across read_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:

  • Implemented search in all three places that expose taxonomy tools (the direct read_taxonomy MCP tool, the query-planner sub-agent, and the taxonomy sub-agent), since the report called out both read_taxonomy and the sub-agent toolkit as needing the fix, and they turned out to be three separate (non-shared) implementations.
  • Kept the search scoped to name + description matching via existing PropertyDefinition/EnterprisePropertyDefinition queries rather than adding new infrastructure (embeddings, fuzzy matching), to stay contained and consistent with how descriptions are already surfaced elsewhere.
  • No skills were invoked for this change (no DRF endpoint, migration, or frontend copy involved).

Created with PostHog Desktop from this inbox report

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
@trunk-io

trunk-io Bot commented Aug 2, 2026

Copy link
Copy Markdown

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

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.

0 participants