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

Abierto
#1,666 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
3.9k
Forks
853
Merge medio
1 d 18 h
PR fusionados (30 d)
11

Descripción

## 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).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.