Python SDK middleware now receives the client's default headers including credentials, so logging middleware must redact them, and header-override order matters.
Key takeaways · AI-distilled
Anthropic's Python SDK 2.17.0 shows middleware the ClientThe program that sends a request to a server and receives its response.Full definition →'s default headers and credentials, including `AuthorizationThe check that an authenticated identity is permitted to perform a particular operation on a particular resource.Full definition →`, in `APIRequest.headers`. Middleware that logs those headers should redact credentials, and forwarding them to another client now passes this client's key.
Dropped streams and JSONL responses such as Message Batches results now raise `anthropic.APIConnectionError`, or `APITimeoutError` for timeouts, instead of raw `httpx2` errors, after yielding every complete line. Requests are not resent.
The plain-HTTP exception for the token exchange now matches loopback hosts exactly, so look-alike URLs such as `http://localhost.example.com` or `http://localhost@example.com` raise `CredentialsError` instead of being accepted.
In the environment worker, a memory-file `write` or `edit` now uploads first and returns an error if the store refuses it, another SessionOne conversation or piece of work as a harness keeps it: a record of messages, tool calls and observations that can be saved and resumed.Full definition → changed the memory, or the upload is not confirmed within 30 seconds.
Terms in this piece · Glossary
agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.
Client — The program that sends a request to a server and receives its response.
Authorization — The check that an authenticated identity is permitted to perform a particular operation on a particular resource.
Session — One conversation or piece of work as a harness keeps it: a record of messages, tool calls and observations that can be saved and resumed.