8be7c93063
* Python: Preserve structured instructions when merging chat options `instructions` is declared as `str` on `ChatOptions`, but chat clients may widen it to a provider-native structured form. Three merge paths combined it with an f-string, which coerced any non-string value to its `repr`, turning structured metadata into literal text before any client could see it: - `merge_chat_options` (`_types.py`) - `_merge_options` (`_agents.py`, agent defaults + per-run options) - provider-contributed instructions in `_prepare_session_and_messages` (`_agents.py`) The last of these is the reported case: once any context provider (for example `SkillsProvider`) contributes instructions, structured instructions were replaced by their `repr`, so the model received Python dict syntax as its system prompt and Anthropic prompt caching silently stopped working. Add a shared `_append_instructions` helper that concatenates strings as before and otherwise extends element-wise, always appending so the leading portion stays unchanged for providers that treat it as a stable, structure-sensitive prefix. A lone mapping is treated as a single element rather than iterated into its keys. On the Anthropic side, `_extract_structured_instructions` now normalizes bare strings into text blocks, since appended instructions arrive alongside caller-supplied blocks. Fixes #7700 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f428b149-a306-484a-b423-4e9de69f0b90 * Python: address review feedback on structured instructions fix Parameterize the Anthropic regression test over both the with- and without-SkillsProvider configurations so the structure-preserving behavior is asserted in the baseline case too. Normalize structured instructions in `_get_instructions_from_options` so telemetry records the instruction text for provider-native block shapes, extracting only `text` values to keep provider metadata out of spans. Use `cast` for the structured `default_options` in both regression tests so the test type checkers resolve the client options type correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f428b149-a306-484a-b423-4e9de69f0b90 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com> Copilot-Session: f428b149-a306-484a-b423-4e9de69f0b90