Build model settings with the correct token parameter.
(config: Config, model_name: str)
| 39 | part-level marker would land on a nested block, which Anthropic rejects. |
| 40 | Other roles get it on the last content part (string content is converted to |
| 41 | a single text part). |
| 42 | """ |
| 43 | if message.get("role") == "tool": |
| 44 | message.setdefault("cache_control", dict(_EPHEMERAL_CACHE)) |
| 45 | return |
| 46 | content = message.get("content") |
| 47 | if isinstance(content, str) and content: |
| 48 | message["content"] = [ |
| 49 | {"type": "text", "text": content, "cache_control": dict(_EPHEMERAL_CACHE)} |
| 50 | ] |
| 51 | elif isinstance(content, list) and content: |
| 52 | last_part = content[-1] |
| 53 | if isinstance(last_part, dict): |
| 54 | last_part.setdefault("cache_control", dict(_EPHEMERAL_CACHE)) |
no test coverage detected