Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(user-interviews): add USER_INTERVIEW agent mode so Max can call the create-topic tool (#59221)

Kim Svatos Dugan50f7a6fcf03b
diff --git a/ee/hogai/chat_agent/mode_manager.py b/ee/hogai/chat_agent/mode_manager.py
index df80c6f9aba7..41fff184025b 100644
--- a/ee/hogai/chat_agent/mode_manager.py
+++ b/ee/hogai/chat_agent/mode_manager.py
@@ -25,9 +25,14 @@ from ee.hogai.core.agent_modes.presets.product_analytics import (
from ee.hogai.core.agent_modes.presets.session_replay import chat_agent_plan_session_replay_agent, session_replay_agent
from ee.hogai.core.agent_modes.presets.sql import chat_agent_plan_sql_agent, sql_agent
from ee.hogai.core.agent_modes.presets.survey import chat_agent_plan_survey_agent, subagent_survey_agent, survey_agent
+from ee.hogai.core.agent_modes.presets.user_interview import (
+ chat_agent_plan_user_interview_agent,
+ subagent_user_interview_agent,
+ user_interview_agent,
+)
from ee.hogai.core.agent_modes.prompt_builder import AgentPromptBuilder
from ee.hogai.core.agent_modes.toolkit import AgentToolkit, AgentToolkitManager
-from ee.hogai.utils.feature_flags import has_plan_mode_feature_flag
+from ee.hogai.utils.feature_flags import has_plan_mode_feature_flag, has_user_interview_mode_feature_flag
from ee.hogai.utils.types.base import AssistantState, NodePath
# Execution and plan mode definitions - fictitious modes used to trigger transition in and out of plan mode
@@ -77,7 +82,10 @@ SUBAGENT_CHAT_AGENT_MODE_REGISTRY: dict[AgentMode, AgentModeDefinition] = {
def get_plan_mode_registry(team: Team, user: User) -> dict[AgentMode, AgentModeDefinition]:
- return dict(DEFAULT_CHAT_AGENT_PLAN_MODE_REGISTRY)
+ registry = dict(DEFAULT_CHAT_AGENT_PLAN_MODE_REGISTRY)
+ if has_user_interview_mode_feature_flag(team, user):
+ registry[AgentMode.USER_INTERVIEW] = chat_agent_plan_user_interview_agent
+ return registry
def get_execution_mode_registry(team: Team, user: User) -> dict[AgentMode, AgentModeDefinition]:
@@ -85,7 +93,10 @@ def get_execution_mode_registry(team: Team, user: User) -> dict[AgentMode, Agent
This is the registry that will be available after transitioning out of plan mode.
"""
- return dict(DEFAULT_CHAT_AGENT_MODE_REGISTRY)
+ registry = dict(DEFAULT_CHAT_AGENT_MODE_REGISTRY)
+ if has_user_interview_mode_feature_flag(team, user):
+ registry[AgentMode.USER_INTERVIEW] = user_interview_agent
+ return registry
class ChatAgentModeManager(AgentModeManager):
@@ -136,7 +147,10 @@ class ChatAgentModeManager(AgentModeManager):
@property
def _subagent_mode_registry(self) -> dict[AgentMode, AgentModeDefinition]:
- return dict(SUBAGENT_CHAT_AGENT_MODE_REGISTRY)
+ registry = dict(SUBAGENT_CHAT_AGENT_MODE_REGISTRY)
+ if has_user_interview_mode_feature_flag(self._team, self._user):
+ registry[AgentMode.USER_INTERVIEW] = subagent_user_interview_agent
+ return registry
@property
def prompt_builder_class(self) -> type[AgentPromptBuilder]:
diff --git a/ee/hogai/core/agent_modes/presets/test/test_user_interview_preset.py b/ee/hogai/core/agent_modes/presets/test/test_user_interview_preset.py
new file mode 100644
index 000000000000..dba762d153c6
--- /dev/null
+++ b/ee/hogai/core/agent_modes/presets/test/test_user_interview_preset.py
@@ -0,0 +1,59 @@
+from unittest import TestCase
+from unittest.mock import MagicMock
+
+from parameterized import parameterized
+
+from posthog.schema import AgentMode
+
+from ..user_interview import (
+ ReadOnlyUserInterviewAgentToolkit,
+ UserInterviewAgentToolkit,
+ chat_agent_plan_user_interview_agent,
+ subagent_user_interview_agent,
+ user_interview_agent,
+)
+
+
+def _make_toolkit(toolkit_class):
+ # The `tools` property only imports and returns classes — it never touches `_team`,
+ # `_user`, or `_context_manager`, so mocks are sufficient and keep the test DB-free.
+ return toolkit_class(team=MagicMock(), user=MagicMock(), context_manager=MagicMock())
+
+
+class TestUserInterviewAgentToolkit(TestCase):
+ def test_toolkit_includes_both_user_interview_tools(self):
+ tool_class_names = [tool_class.__name__ for tool_class in _make_toolkit(UserInterviewAgentToolkit).tools]
+
+ self.assertIn("CreateUserInterviewTopicTool", tool_class_names)
+ self.assertIn("AnalyzeUserInterviewsTool", tool_class_names)
+
+ def test_read_only_toolkit_excludes_create_tool(self):
+ tool_class_names = [
+ tool_class.__name__ for tool_class in _make_toolkit(ReadOnlyUserInterviewAgentToolkit).tools
+ ]
+
+ self.assertEqual(tool_class_names, ["AnalyzeUserInterviewsTool"])
+
+ def test_toolkit_has_trajectory_examples(self):
+ examples = UserInterviewAgentToolkit.POSITIVE_TODO_EXAMPLES
+ self.assertIsNotNone(examples)
+ self.assertGreater(len(examples), 0)
+
+ @parameterized.expand(
+ [
+ ("user_interview_agent", user_interview_agent),
+ ("subagent_user_interview_agent", subagent_user_interview_agent),
+ ("chat_agent_plan_user_interview_agent", chat_agent_plan_user_interview_agent),
+ ]
+ )
+ def test_mode_definition_uses_user_interview_mode(self, _name, definition):
+ self.assertEqual(definition.mode, AgentMode.USER_INTERVIEW)
+
+ @parameterized.expand(
+ [
+ ("subagent_user_interview_agent", subagent_user_interview_agent),
+ ("chat_agent_plan_user_interview_agent", chat_agent_plan_user_interview_agent),
+ ]
+ )
+ def test_read_only_variants_use_read_only_toolkit(self, _name, definition):
+ self.assertEqual(definition.toolkit_class, ReadOnlyUserInterviewAgentToolkit)
diff --git a/ee/hogai/core/agent_modes/presets/user_interview.py b/ee/hogai/core/agent_modes/presets/user_interview.py
new file mode 100644
index 000000000000..71844a86f72e
--- /dev/null
+++ b/ee/hogai/core/agent_modes/presets/user_interview.py
@@ -0,0 +1,127 @@
+from dataclasses import replace
+from typing import TYPE_CHECKING
+
+from posthog.schema import AgentMode
+
+from ee.hogai.chat_agent.executables import ChatAgentPlanExecutable, ChatAgentPlanToolsExecutable
+from ee.hogai.core.agent_modes.factory import AgentModeDefinition
+from ee.hogai.core.agent_modes.toolkit import AgentToolkit
+from ee.hogai.tools.todo_write import TodoWriteExample
+
+if TYPE_CHECKING:
+ from ee.hogai.tool import MaxTool
+
+
+POSITIVE_EXAMPLE_CREATE_TOPIC_BY_EMAILS = """
+User: Set up an interview about the new dashboard onboarding with [email protected] and [email protected]
+Assistant: I'll create an interview topic about the dashboard onboarding flow targeting those two users.
+*Uses create_user_interview_topic with topic, interviewee_emails, and 3-5 open-ended questions*
+The topic is created — you can send invites from the topic page.
+""".strip()
+
+POSITIVE_EXAMPLE_CREATE_TOPIC_BY_EMAILS_REASONING = """
+The assistant used create_user_interview_topic because:
+1. The user wants live AI voice interviews, not an in-app survey
+2. Participant emails are provided directly, so no cohort/persons lookup is needed
+3. The assistant drafts conversational, open-ended questions in topic order
+""".strip()
+
+POSITIVE_EXAMPLE_CREATE_TOPIC_FROM_COHORT = """
+User: Talk to users in the "Power users" cohort about how they use saved insights
+Assistant: I'll first resolve the cohort to distinct IDs, then create the interview topic.
+*Creates todo list with the following items:*
+1. Search for the "Power users" cohort and resolve its members to distinct IDs
+2. Create the interview topic with those distinct IDs and a question list
+*Uses search with kind: "cohorts" and query: "Power users"*
+After resolving members, the assistant calls create_user_interview_topic with interviewee_distinct_ids.
+""".strip()
+
+POSITIVE_EXAMPLE_CREATE_TOPIC_FROM_COHORT_REASONING = """
+The assistant used the todo list because:
+1. Targeting by cohort needs two steps: resolve the cohort, then create the topic
+2. create_user_interview_topic accepts distinct IDs or emails but does not look up cohorts itself
+3. Breaking it into steps prevents inventing or mis-targeting participants
+""".strip()
+
+POSITIVE_EXAMPLE_ANALYZE_INTERVIEWS = """
+User: What patterns are coming out of our recent user interviews?
+Assistant: I'll analyze the interview summaries for common themes.
+*Uses analyze_user_interviews with an analysis_angle describing the question*
+Here are the themes I found across the interviews: ...
+""".strip()
+
+POSITIVE_EXAMPLE_ANALYZE_INTERVIEWS_REASONING = """
+The assistant used analyze_user_interviews because:
+1. The user wants insights from already-conducted interviews, not to create a new topic
+2. The tool reads existing interview summaries for the team
+3. The analysis_angle steers the LLM toward the user's question
+""".strip()
+
+
+USER_INTERVIEW_MODE_DESCRIPTION = (
+ "Specialized mode for setting up and analyzing live AI voice user interviews. "
+ "Use this mode when the user wants to interview users, talk to customers, run user research "
+ "calls, or analyze interview transcripts. This is NOT a survey mode — interviews are live "
+ "voice conversations, not in-app survey widgets."
+)
+
+
+class UserInterviewAgentToolkit(AgentToolkit):
+ POSITIVE_TODO_EXAMPLES = [
+ TodoWriteExample(
+ example=POSITIVE_EXAMPLE_CREATE_TOPIC_BY_EMAILS,
+ reasoning=POSITIVE_EXAMPLE_CREATE_TOPIC_BY_EMAILS_REASONING,
+ ),
+ TodoWriteExample(
+ example=POSITIVE_EXAMPLE_CREATE_TOPIC_FROM_COHORT,
+ reasoning=POSITIVE_EXAMPLE_CREATE_TOPIC_FROM_COHORT_REASONING,
+ ),
+ TodoWriteExample(
+ example=POSITIVE_EXAMPLE_ANALYZE_INTERVIEWS,
+ reasoning=POSITIVE_EXAMPLE_ANALYZE_INTERVIEWS_REASONING,
+ ),
+ ]
+
+ @property
+ def tools(self) -> list[type["MaxTool"]]:
+ from products.user_interviews.backend.facade.api import AnalyzeUserInterviewsTool, CreateUserInterviewTopicTool
+
+ tools: list[type[MaxTool]] = [CreateUserInterviewTopicTool, AnalyzeUserInterviewsTool]
+ return tools
+
+
+user_interview_agent = AgentModeDefinition(
+ mode=AgentMode.USER_INTERVIEW,
+ mode_description=USER_INTERVIEW_MODE_DESCRIPTION,
+ toolkit_class=UserInterviewAgentToolkit,
+)
+
+
+class ReadOnlyUserInterviewAgentToolkit(AgentToolkit):
+ """User interview toolkit for subagents — only includes AnalyzeUserInterviewsTool (read-only)."""
+
+ @property
+ def tools(self) -> list[type["MaxTool"]]:
+ from products.user_interviews.backend.facade.api import AnalyzeUserInterviewsTool
+
+ return [AnalyzeUserInterviewsTool]
+
+
+READ_ONLY_USER_INTERVIEW_MODE_DESCRIPTION = (
+ "Specialized mode for analyzing user interviews. Read summaries of past interviews to extract "
+ "themes, pain points, and feature requests."
+)
+
+subagent_user_interview_agent = replace(
+ user_interview_agent,
+ toolkit_class=ReadOnlyUserInterviewAgentToolkit,
+ mode_description=READ_ONLY_USER_INTERVIEW_MODE_DESCRIPTION,
+)
+
+chat_agent_plan_user_interview_agent = AgentModeDefinition(
+ mode=AgentMode.USER_INTERVIEW,
+ mode_description=READ_ONLY_USER_INTERVIEW_MODE_DESCRIPTION,
+ toolkit_class=ReadOnlyUserInterviewAgentToolkit,
+ node_class=ChatAgentPlanExecutable,
+ tools_node_class=ChatAgentPlanToolsExecutable,
+)
diff --git a/ee/hogai/utils/feature_flags.py b/ee/hogai/utils/feature_flags.py
index 8409806e8578..0d197e4e88ba 100644
--- a/ee/hogai/utils/feature_flags.py
+++ b/ee/hogai/utils/feature_flags.py
@@ -101,6 +101,16 @@ def has_sandbox_mode_feature_flag(team: Team, user: User) -> bool:
)
+def has_user_interview_mode_feature_flag(team: Team, user: User) -> bool:
+ return posthoganalytics.feature_enabled(
+ "user-interviews",
+ str(user.distinct_id),
+ groups={"organization": str(team.organization_id)},
+ group_properties={"organization": {"id": str(team.organization_id)}},
+ send_feature_flag_events=False,
+ )
+
+
def get_llm_gateway_variant(team: Team, user: User) -> LlmGatewayVariant:
variant = cast(
"str | bool | None",
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 04041d84462a..933ac5700e61 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -371,7 +371,8 @@
"research",
"flags",
"llm_analytics",
- "sandbox"
+ "sandbox",
+ "user_interview"
],
"type": "string"
},
diff --git a/frontend/src/queries/schema/schema-assistant-messages.ts b/frontend/src/queries/schema/schema-assistant-messages.ts
index 8885ca8dc25f..b3feadd000a2 100644
--- a/frontend/src/queries/schema/schema-assistant-messages.ts
+++ b/frontend/src/queries/schema/schema-assistant-messages.ts
@@ -512,6 +512,7 @@ export enum AgentMode {
Flags = 'flags',
LLMAnalytics = 'llm_analytics',
Sandbox = 'sandbox',
+ UserInterview = 'user_interview',
}
export enum SlashCommandName {
diff --git a/frontend/src/scenes/max/max-constants.tsx b/frontend/src/scenes/max/max-constants.tsx
index 7ca3035a8b46..9282f0059edc 100644
--- a/frontend/src/scenes/max/max-constants.tsx
+++ b/frontend/src/scenes/max/max-constants.tsx
@@ -535,6 +535,7 @@ export const TOOL_DEFINITIONS: Record<AssistantTool, ToolDefinition> = {
product: Scene.UserInterviews,
flag: FEATURE_FLAGS.USER_INTERVIEWS,
icon: iconForType('user_interview'),
+ modes: [AgentMode.UserInterview],
displayFormatter: (toolCall) => {
if (toolCall.status === 'completed') {
return 'Analyzed user interviews'
@@ -548,6 +549,7 @@ export const TOOL_DEFINITIONS: Record<AssistantTool, ToolDefinition> = {
product: Scene.UserInterviews,
flag: FEATURE_FLAGS.USER_INTERVIEWS,
icon: iconForType('user_interview'),
+ modes: [AgentMode.UserInterview],
displayFormatter: (toolCall) => {
if (toolCall.status === 'completed') {
return 'Created interview topic'
@@ -1126,6 +1128,13 @@ export const MODE_DEFINITIONS: Record<
Scene.LLMAnalyticsUsers,
]),
},
+ [AgentMode.UserInterview]: {
+ name: 'User interviews',
+ description: 'Sets up live AI voice interviews and analyzes interview transcripts.',
+ icon: iconForType('user_interview'),
+ scenes: new Set([Scene.UserInterviews, Scene.UserInterview, Scene.UserInterviewResponse]),
+ flag: 'USER_INTERVIEWS',
+ },
}
export const SPECIAL_MODES: Record<string, ModeDefinition> = {
diff --git a/posthog/schema.py b/posthog/schema.py
index 9c15c2f0a838..efd4bccbd187 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -50,6 +50,7 @@ class AgentMode(StrEnum):
FLAGS = "flags"
LLM_ANALYTICS = "llm_analytics"
SANDBOX = "sandbox"
+ USER_INTERVIEW = "user_interview"
class AggregationAxisFormat(StrEnum):
diff --git a/products/conversations/frontend/generated/api.schemas.ts b/products/conversations/frontend/generated/api.schemas.ts
index 0d1b10e1049c..754bf5d4ef1a 100644
--- a/products/conversations/frontend/generated/api.schemas.ts
+++ b/products/conversations/frontend/generated/api.schemas.ts
@@ -144,6 +144,7 @@ export type MessageApiContextualTools = { [key: string]: unknown }
* `flags` - flags
* `llm_analytics` - llm_analytics
* `sandbox` - sandbox
+ * `user_interview` - user_interview
*/
export type AgentModeEnumApi = (typeof AgentModeEnumApi)[keyof typeof AgentModeEnumApi]
@@ -159,6 +160,7 @@ export const AgentModeEnumApi = {
Flags: 'flags',
LlmAnalytics: 'llm_analytics',
Sandbox: 'sandbox',
+ UserInterview: 'user_interview',
} as const
/**
diff --git a/products/conversations/frontend/generated/api.zod.ts b/products/conversations/frontend/generated/api.zod.ts
index d803d94d61d6..a6a943e9447a 100644
--- a/products/conversations/frontend/generated/api.zod.ts
+++ b/products/conversations/frontend/generated/api.zod.ts
@@ -41,10 +41,11 @@ export const ConversationsCreateBody = /* @__PURE__ */ zod
'flags',
'llm_analytics',
'sandbox',
+ 'user_interview',
])
.optional()
.describe(
- '\* `product_analytics` - product_analytics\n\* `sql` - sql\n\* `session_replay` - session_replay\n\* `error_tracking` - error_tracking\n\* `plan` - plan\n\* `execution` - execution\n\* `survey` - survey\n\* `research` - research\n\* `flags` - flags\n\* `llm_analytics` - llm_analytics\n\* `sandbox` - sandbox'
+ '\* `product_analytics` - product_analytics\n\* `sql` - sql\n\* `session_replay` - session_replay\n\* `error_tracking` - error_tracking\n\* `plan` - plan\n\* `execution` - execution\n\* `survey` - survey\n\* `research` - research\n\* `flags` - flags\n\* `llm_analytics` - llm_analytics\n\* `sandbox` - sandbox\n\* `user_interview` - user_interview'
),
is_sandbox: zod.boolean().default(conversationsCreateBodyIsSandboxDefault),
resume_payload: zod.unknown().optional(),
diff --git a/products/user_interviews/backend/facade/api.py b/products/user_interviews/backend/facade/api.py
index d6b561e1c3bb..fa18ff3e8ec0 100644
--- a/products/user_interviews/backend/facade/api.py
+++ b/products/user_interviews/backend/facade/api.py
@@ -18,6 +18,15 @@ from uuid import UUID
from products.user_interviews.backend import logic
from products.user_interviews.backend.facade.contracts import IntervieweeIdentity
+from products.user_interviews.backend.max_tools import AnalyzeUserInterviewsTool, CreateUserInterviewTopicTool
+
+__all__ = [
+ "AnalyzeUserInterviewsTool",
+ "CreateUserInterviewTopicTool",
+ "IntervieweeIdentity",
+ "has_replied",
+ "parse_interviewee_identifier",
+]
def parse_interviewee_identifier(identifier: str) -> IntervieweeIdentity:
diff --git a/products/user_interviews/backend/max_tools.py b/products/user_interviews/backend/max_tools.py
index e05706ffa7b9..43a0276e9871 100644
--- a/products/user_interviews/backend/max_tools.py
+++ b/products/user_interviews/backend/max_tools.py
@@ -32,6 +32,9 @@ class AnalyzeUserInterviewsTool(MaxTool):
context_prompt_template: str = "Since the user is currently on the user interviews page, you should lean towards the `analyze_user_interviews` when it comes to any questions about users or customers."
args_schema: type[BaseModel] = AnalyzeUserInterviewsArgs
+ def get_required_resource_access(self) -> list[tuple[APIScopeObject, AccessControlLevel]]:
+ return [("user_interview", "viewer")]
+
def _run_impl(self, analysis_angle: str) -> tuple[str, Any]:
# Get all interviews for the current team
interviews = UserInterview.objects.filter(team=self._team).order_by("-created_at")
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 010217dbceea..9910f4998110 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -3636,6 +3636,7 @@ export namespace Schemas {
* `flags` - flags
* `llm_analytics` - llm_analytics
* `sandbox` - sandbox
+ * `user_interview` - user_interview
*/
export type AgentModeEnum = typeof AgentModeEnum[keyof typeof AgentModeEnum];
@@ -3652,6 +3653,7 @@ export namespace Schemas {
Flags: 'flags',
LlmAnalytics: 'llm_analytics',
Sandbox: 'sandbox',
+ UserInterview: 'user_interview',
} as const;
export interface AggregatedSpanRow {
diff --git a/tach.toml b/tach.toml
index 8b14a2c8dcec..a4d25068ec54 100644
--- a/tach.toml
+++ b/tach.toml
@@ -50,6 +50,7 @@ depends_on = [
"products.revenue_analytics",
"products.surveys",
"products.tasks",
+ "products.user_interviews",
]
layer = "modules"