diff --git a/.sampo/changesets/persistent-conversation-id.md b/.sampo/changesets/persistent-conversation-id.md new file mode 100644 index 000000000..7164b2d05 --- /dev/null +++ b/.sampo/changesets/persistent-conversation-id.md @@ -0,0 +1,5 @@ +--- +pypi/posthog: patch +--- + +Keep MCP conversation sessions consistent across user messages. diff --git a/posthog/mcp/constants.py b/posthog/mcp/constants.py index 75dff21b8..85f2fed63 100644 --- a/posthog/mcp/constants.py +++ b/posthog/mcp/constants.py @@ -28,8 +28,11 @@ ) DEFAULT_CONVERSATION_ID_DESCRIPTION = ( - "Echo the conversation_id from the server's previous response. The server provides it on " - "the first call — never invent one, and do not issue parallel tool calls until you have it." + "Pass the exact conversation_id from the server's previous response, unchanged. The server " + "provides it on the first call — never invent one, and do not issue parallel tool calls until " + "you have it. Keep passing the same conversation_id for the rest of the conversation, including " + "after later user messages or on a different task; do not reset it when the user starts a new " + "request." ) DEFAULT_MODEL_PARAMETER_DESCRIPTION = ( diff --git a/posthog/test/mcp/test_units.py b/posthog/test/mcp/test_units.py index ef122d9fc..2fff89e6a 100644 --- a/posthog/test/mcp/test_units.py +++ b/posthog/test/mcp/test_units.py @@ -230,6 +230,11 @@ def test_add_conversation_id_adds_property(): {"type": "object", "properties": {"x": {"type": "string"}}}, "t" ) assert out["properties"]["conversation_id"]["type"] == "string" + # Without this clause, ChatGPT drops the handle on each new user message and every message becomes its own session. + assert ( + "rest of the conversation, including after later user messages" + in out["properties"]["conversation_id"]["description"] + ) def test_add_conversation_id_skips_when_already_present():