From 1dfc75520dd780e2f713bb7ff72bafed2d8190e3 Mon Sep 17 00:00:00 2001 From: majdyz Date: Wed, 22 Apr 2026 00:28:13 +0700 Subject: [PATCH] fix(backend/copilot): drop encrypted_content from web_search snippet Anthropic's web_search_result ships an opaque encrypted_content blob meant for citation round-tripping, not display. Using it as the snippet surfaced base64 gibberish to the frontend and to the LLM. There is no plain-text snippet field in the current beta; drop it and rely on the model's text blocks with citations for prose. --- .../backend/backend/copilot/tools/web_search.py | 13 ++++++++++--- .../backend/copilot/tools/web_search_test.py | 10 +++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/autogpt_platform/backend/backend/copilot/tools/web_search.py b/autogpt_platform/backend/backend/copilot/tools/web_search.py index 4b7ac3a53f..22d9a82904 100644 --- a/autogpt_platform/backend/backend/copilot/tools/web_search.py +++ b/autogpt_platform/backend/backend/copilot/tools/web_search.py @@ -183,13 +183,20 @@ def _extract_results(resp: Any, *, limit: int) -> tuple[list[WebSearchResult], i continue if len(results) >= limit: break + # Anthropic's ``web_search_result`` exposes only + # ``title``/``url``/``page_age`` plus an opaque + # ``encrypted_content`` blob that is meant for citation + # round-tripping, not for display — it is base64-ish + # binary and would show as gibberish if surfaced to the + # model or the frontend. There is no plain-text snippet + # field in the current beta; callers get the readable + # text via the model's ``text`` blocks with citations, + # not via this list. Leave ``snippet`` empty. results.append( WebSearchResult( title=getattr(item, "title", "") or "", url=getattr(item, "url", "") or "", - snippet=getattr(item, "encrypted_content", None) - or getattr(item, "page_content", "") - or "", + snippet="", page_age=getattr(item, "page_age", None), ) ) diff --git a/autogpt_platform/backend/backend/copilot/tools/web_search_test.py b/autogpt_platform/backend/backend/copilot/tools/web_search_test.py index fe7885e171..3d516f295a 100644 --- a/autogpt_platform/backend/backend/copilot/tools/web_search_test.py +++ b/autogpt_platform/backend/backend/copilot/tools/web_search_test.py @@ -64,13 +64,17 @@ class TestExtractResults: """The extractor is the only Anthropic-response-shape contact point; pin its behaviour so an API shape change surfaces here first.""" - def test_extracts_title_url_snippet_and_page_age(self): + def test_extracts_title_url_page_age_and_drops_encrypted_snippet(self): + # Anthropic's ``web_search_result`` ships an opaque + # ``encrypted_content`` blob that is not safe to surface — + # the extractor must drop it (snippet=="") regardless of + # whether the blob is non-empty. resp = _fake_anthropic_response( results=[ { "title": "Kimi K2.6 launch", "url": "https://example.com/kimi", - "snippet": "Moonshot released K2.6 on 2026-04-20.", + "snippet": "EiJjbGF1ZGUtZW5jcnlwdGVkLWJsb2I=", "page_age": "1 day", }, { @@ -85,7 +89,7 @@ class TestExtractResults: assert len(out) == 2 assert out[0].title == "Kimi K2.6 launch" assert out[0].url == "https://example.com/kimi" - assert out[0].snippet.startswith("Moonshot released") + assert out[0].snippet == "" assert out[0].page_age == "1 day" assert out[1].snippet == ""