You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(context): decrease token in web_search AIMessage (bytedance#827)
This PR addresses token limit issues when web_search is enabled with include_raw_content by implementing a two-pronged approach: changing the default behavior to exclude raw content and adding compression logic for when raw content is included.
"""Test compress_messages preserves system message and compresses raw_content"""
90
90
# Create a context manager with limited token capacity
91
91
limited_cm=ContextManager(token_limit=200)
92
92
93
93
messages= [
94
94
SystemMessage(content="You are a helpful assistant."),
95
95
HumanMessage(content="Hello"),
96
96
AIMessage(content="Hi there!"),
97
-
HumanMessage(
98
-
content="Can you tell me a very long story that would exceed token limits? "
99
-
*100
100
-
),
97
+
ToolMessage(
98
+
name="web_search",
99
+
content='[{"title": "Test Result", "url": "https://example.com", "raw_content": "'+ ("This is a test content that should be compressed if it exceeds 1024 characters. "*2000) +'"}]',
content="Can you tell me a very long story that would exceed token limits? "*100
203
214
),
215
+
ToolMessage(
216
+
name="web_search",
217
+
content='[{"title": "Test Result", "url": "https://example.com", "raw_content": "'+ ("This is a test content that should be compressed if it exceeds 1024 characters. "*2000) +'"}]',
0 commit comments