-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Context
Web search results include large encryptedContent fields (4000+ chars each, base64-encoded page content) that consume massive amounts of tokens. In one conversation, 5 web searches with 23 results consumed 83,569 out of 102,431 chars (82%) of the message history, causing the conversation to hit the 200k token limit prematurely.
Current Solution
Added stripEncryptedContent() transformation in modelMessageTransform.ts that removes these fields before sending messages to the API, keeping only URL, title, and pageAge.
Questions
-
Is the encrypted content actually useful for the model? Does Claude benefit from having the full page content, or are URL/title/pageAge sufficient?
-
Should this be handled upstream? Should the web search tool itself return a condensed format, or should we filter it in the message transform layer?
-
Is there a middle ground? Could we include a summary or first N chars instead of stripping completely?
-
Does this affect model quality? Need to test if removing this content degrades the model's ability to answer questions based on web search results.
Related
- File:
src/utils/modelMessageTransform.ts:329-380 - Added in response to token exhaustion issue