You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 42d6ea8
Browse filesBrowse the repository at this point in the historyBrowse files
Python: Replay Anthropic redacted_thinking blocks in tool loops
redacted_thinking blocks were parsed through the default branch and recorded as dropped content, so the function-invocation loop replayed the assistant turn without them. Anthropic requires the thinking blocks of the last assistant turn, including redacted ones, to be returned unmodified while tool use continues.
Parse redacted_thinking into its own reasoning item carrying the opaque payload in Content.protected_data plus an anthropic namespace marker, following the existing Bedrock redacted-reasoning pattern. Serialize marked items back as redacted_thinking blocks, give each parsed reasoning block its own identity so streaming aggregation keeps thinking and redacted_thinking blocks separate, and fail before the request when a marked item cannot be reconstructed. pause_turn continuations can now replay redacted reasoning instead of stopping early.
Fixesmicrosoft#10104
Copy file name to clipboardExpand all lines: docs/specs/004-python-function-calling-loop.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -616,7 +616,7 @@ that manually replay messages own the equivalent rule: do not resend an approval
616
616
| Declaration-only mixed batch | Known local siblings are never converted into Host pauses. With an authoritative session they remain deferred until every Host pause occurrence is answered, survive session serialization with a process-portable logical-run budget (including a reclassified approval continuation), reclassify against the current tool policy, execute exactly once using the configured concurrent or sequential invocation mode, replay results in original model order, and remain inert on replay; without one they execute on the same turn under the same configured invocation mode. Streaming updates and finalization preserve one Host pause and one result per local sibling. | `test_mixed_declaration_only_batch_defers_siblings_until_all_host_results`, `test_mixed_declaration_only_deferred_call_keeps_ordinary_middleware_semantics`, `test_mixed_declaration_only_deferred_call_reclassifies_changed_approval_policy`, `test_mixed_declaration_only_budget_survives_reclassification_to_approval`, `test_mixed_declaration_only_deferred_call_does_not_execute_removed_tool`, `test_mixed_declaration_only_budget_is_process_portable_without_approval_middleware`, `test_sessionless_mixed_declaration_only_batch_executes_siblings_sequentially`, `test_sessionless_mixed_declaration_only_batch_executes_siblings_concurrently`, `test_streaming_sessionless_mixed_declaration_only_batch_returns_pause_and_result` |
617
617
| Function invocation disabled | The client bypasses the invocation loop without losing invocation kwargs. |`test_function_invocation_config_enabled_false`, `test_function_invocation_config_enabled_false_preserves_invocation_kwargs`, `test_streaming_function_invocation_config_enabled_false`|
618
618
| Runtime tool changes | Added tools become available on the next iteration and retain approval behavior. |`test_add_tools_available_next_iteration`, `test_add_tools_with_approval_required_tool`|
619
-
| Anthropic pause-turn continuation | `pause_turn` replays the returned assistant content with the same tools until Anthropic completes the server-side turn in streaming and non-streaming modes when every native content block can be reconstructed faithfully. Intermediate messages and usage remain caller-visible and retain provider message boundaries. Unsupported parsed content, native blocks dropped during parsing (including redacted reasoning), streamed MCP calls whose argument deltas are not retained, and bounded-continuation exhaustion keep `finish_reason="pause_turn"` instead of sending a lossy transcript or reporting normal completion. | `packages/anthropic/tests/test_anthropic_client.py::test_agent_continues_anthropic_pause_turn`, `test_streaming_hosted_tool_pause_turn_continues`, `test_streaming_pause_turn_preserves_message_boundaries_for_structured_output`, `test_non_streaming_code_execution_pause_turn_is_not_auto_continued`, `test_streaming_code_execution_pause_turn_is_not_auto_continued`, `test_streaming_mcp_pause_turn_is_not_auto_continued`, `test_non_streaming_redacted_thinking_pause_turn_is_not_auto_continued`, `test_streaming_redacted_thinking_pause_turn_is_not_auto_continued`, `test_anthropic_pause_turn_limit_preserves_finish_reason` |
619
+
| Anthropic pause-turn continuation | `pause_turn` replays the returned assistant content with the same tools until Anthropic completes the server-side turn in streaming and non-streaming modes when every native content block can be reconstructed faithfully. Intermediate messages and usage remain caller-visible and retain provider message boundaries. Unsupported parsed content, native blocks dropped during parsing, streamed MCP calls whose argument deltas are not retained, and bounded-continuation exhaustion keep `finish_reason="pause_turn"` instead of sending a lossy transcript or reporting normal completion. | `packages/anthropic/tests/test_anthropic_client.py::test_agent_continues_anthropic_pause_turn`, `test_streaming_hosted_tool_pause_turn_continues`, `test_streaming_pause_turn_preserves_message_boundaries_for_structured_output`, `test_non_streaming_code_execution_pause_turn_is_not_auto_continued`, `test_streaming_code_execution_pause_turn_is_not_auto_continued`, `test_streaming_mcp_pause_turn_is_not_auto_continued`, `test_non_streaming_redacted_thinking_pause_turn_continues`, `test_streaming_redacted_thinking_pause_turn_continues`, `test_anthropic_pause_turn_limit_preserves_finish_reason` |
620
620
| Direct delegated session propagation | A custom loop must explicitly identify parent provider-owned state before sharing a non-empty session; missing ownership fails before the child runs, while declared parent keys remain isolated and application state still propagates. |`packages/core/tests/core/test_agents.py::test_chat_agent_as_tool_direct_propagation_requires_parent_provider_ownership`, `test_chat_agent_as_tool_direct_propagation_uses_explicit_parent_provider_ownership`|
621
621
| In-run compaction summaries | Summaries inserted for tool groups excluded by in-run compaction are returned in the final non-streaming response transcript before the group they replace, so history loaded with `skip_excluded` keeps the summarized content; summaries of caller-owned input messages are not added. |`packages/core/tests/core/test_clients.py::test_function_loop_returns_compaction_summaries_in_final_response`, `test_function_loop_returns_compaction_summaries_when_iteration_budget_exhausted`, `test_function_loop_reconciles_nested_compaction_summaries`, `test_function_loop_returns_compacted_transcript_on_early_terminal_exit`, `packages/core/tests/core/test_agents.py::test_agent_run_returns_and_persists_compaction_summaries`|
622
622
| Per-service-call provider context | When framework-managed history is loaded around each model call, tools and instructions contributed by `HistoryProvider.before_run` remain available to the model and function loop without duplication in streaming or non-streaming execution. |`packages/core/tests/core/test_agents.py::test_vector_history_search_tool_is_available_with_per_service_call_persistence`|
Copy file name to clipboardExpand all lines: docs/specs/005-python-content-identity-and-protocol-metadata.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -179,6 +179,7 @@ Example:
179
179
| OpenAI | OAuth consent request server |`server_label`|`openai["server_label"]`| Read indefinitely; dual-write through the writer package's next major version. |
180
180
| Foundry | reasoning content |`__foundry_reasoning_replay_item__`|`foundry["reasoning_item"]`| Read indefinitely; dual-write through the Foundry package's next major version. |
181
181
| Bedrock | redacted reasoning marker |`bedrock.redacted_reasoning`|`bedrock["redacted_reasoning"]`| Read indefinitely; dual-write through the Bedrock package's next major version. |
182
+
| Anthropic | native reasoning block type | N/A |`anthropic["reasoning_block"]`| New metadata; values are the Anthropic block types `thinking` and `redacted_thinking`, and a redacted payload uses `Content.protected_data`. |
182
183
| Mistral | response service tier |`service_tier`|`mistral["service_tier"]`| Read indefinitely; dual-write through the Mistral package's next major version. |
183
184
| A2A | response/update/message metadata |`a2a_metadata`|`a2a`| Read indefinitely with a warning for legacy-only input; dual-write through the A2A package's next major version. |
184
185
| all | data/URI/hosted-file display name |`filename`|`Content.name`| Read indefinitely where accepted; dual-write where older adapters require it. |
0 commit comments