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.

fix(posthog-ai): avoid copying search results per message (#114097)

Paul D'Ambrac0aba758218c
diff --git a/products/posthog_ai/frontend/utils/thinkingMessages.ts b/products/posthog_ai/frontend/utils/thinkingMessages.ts
index 891e7966606e..54ff5cce1834 100644
--- a/products/posthog_ai/frontend/utils/thinkingMessages.ts
+++ b/products/posthog_ai/frontend/utils/thinkingMessages.ts
@@ -220,7 +220,7 @@ export const getThinkingMessageFromResponse = (
if (!thinkingMeta) {
return []
}
- const resultsByToolUseId = { ...threadWebSearchResults, ...getWebSearchResultsByToolUseId([message]) }
+ const messageResultsByToolUseId = getWebSearchResultsByToolUseId([message])
const blocks: (ServerToolUseBlock | ThinkingBlock)[] = []
for (const block of thinkingMeta) {
if (block.type === 'thinking') {
@@ -231,7 +231,7 @@ export const getThinkingMessageFromResponse = (
type: 'server_tool_use',
name: block.name as string,
input: block.input as Record<string, unknown>,
- results: resultsByToolUseId[block.id as string],
+ results: messageResultsByToolUseId[block.id as string] ?? threadWebSearchResults?.[block.id as string],
})
} else if (block.type === 'reasoning') {
// OpenAI