anthropics / anthropics/anthropic-sdk-python

web_search_20260209 dynamic filtering: code execution fails with "AttributeError: 'str' object has no attribute 'get'" and returns empty results — need help understanding

未关闭
#1,666 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
3.9k
派生
853
平均合并
1 天 18 小时
30 天内合并 PR
11

描述

## Context

We run an internal Slack assistant on the first-party API using `claude-opus-4-8` with `web_search_20260209` (dynamic filtering), `thinking: {type: "adaptive"}`, and `output_config.effort`. It does web-grounded research (looking things up across a mix of sites) as part of answering.

On some turns, the dynamic-filtering step of `web_search_20260209` fails. The response includes an `encrypted_code_execution_result` block with `return_code: 1` and **empty `content` (`[]`)**, and this stderr:

```
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
...
File "/tmp/srvtoolu_XXXX/cell.py", line 11, in
print(x.get("title"))
^^^^^
AttributeError: 'str' object has no attribute 'get'
```

It looks like the (server-side, model-generated) filtering code iterates over the search results and calls `x.get("title")`, but at least one item `x` comes through as a `str` rather than a `dict`, so it raises. When this happens the search returns nothing useful for that call.

## What we observe

- It's non-deterministic — the same kind of query only hits it on some turns.
- When it fires, the web search contributes no results to that turn, so the answer ends up missing the external context it was trying to gather.
- It's all server-side inside the dynamic-filtering sandbox, so there's nothing in our request we can see to change — hence reaching out.

## Ask

Could your team help us understand what's going on here? Specifically:
- Is this a known issue with `web_search_20260209` dynamic filtering, and is there anything on our side (request shape, parameters) that makes it more or less likely?
- Anything we can do to avoid it while it's investigated (short of dropping back to `web_search_20250305`, which skips dynamic filtering)?

Happy to share a `request_id` privately so you can trace a specific occurrence. This seems related to the dynamic-filtering cluster (#1237, #1224, #1225) but the failure mode is different (filtering code raising → empty results).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。