Skip to content

The agent that grows with you

fix(bedrock): strip prior reasoning for the gpt-6 family on Converse

liuhao1024e49938daf7a6
diff --git a/agent/bedrock_adapter.py b/agent/bedrock_adapter.py
index f4142cb48d1..2a266fd706c 100644
--- a/agent/bedrock_adapter.py
+++ b/agent/bedrock_adapter.py
@@ -864,14 +864,16 @@ def _assistant_blocks(msg: dict, content, claude: bool = True, own: bool = False
# the signature and all previous messages"; Bedrock ignores older turns server-side for free).
# strip — DeepSeek-R1 (AWS's multi-turn sample removes reasoningContent) and Kimi K3 (Converse raises
# InternalServerException "when reasoning content from earlier turns is included"): prior turns
-# lose reasoning, the in-flight loop replays the model's own blocks as captured.
+# lose reasoning, the in-flight loop replays the model's own blocks as captured. Also OpenAI's
+# reasoning GPTs (gpt-6 family): they reject readable reasoningText in assistant history too
+# ("This model doesn't support the reasoningContent.reasoningText.text field").
# unsigned — every other model: prior turns carry readable reasoningText only, since their signatures and
# redacted blobs may be another model's (a /model switch from Claude) and non-Claude models
# reject them ("This model doesn't support the reasoningContent.reasoningText.signature field");
# the in-flight loop was produced by the model now answering and replays as captured.
# A turn stamped by another model (CONVERSE_ISSUER_TYPE) never gets the in-flight verbatim replay: a fallback or
# switch mid-loop hands the loop to a model that cannot open the previous one's sealed blobs (_reasoning_filter).
-_CONVERSE_REPLAY_STRIP_PATTERNS = ("deepseek.r1", "deepseek-r1", "moonshotai.kimi-k3")
+_CONVERSE_REPLAY_STRIP_PATTERNS = ("deepseek.r1", "deepseek-r1", "moonshotai.kimi-k3", "openai.gpt-6")
# reasoning_details record naming the model that minted a turn's Converse reasoning: its signatures are that
diff --git a/tests/agent/test_bedrock_converse_reasoning_replay.py b/tests/agent/test_bedrock_converse_reasoning_replay.py
index f67630ad51d..138d574e13b 100644
--- a/tests/agent/test_bedrock_converse_reasoning_replay.py
+++ b/tests/agent/test_bedrock_converse_reasoning_replay.py
@@ -4,7 +4,8 @@ Converse is the bearer-token Claude path and the sticky fallback after a stream-
error, so a Claude turn captured in Anthropic shape (``anthropic_content_blocks``) must keep its signed
thinking ahead of its toolUse. AWS docs: Claude needs the signature and all previous messages; DeepSeek-R1's
sample removes prior reasoning; Kimi K3 raises InternalServerException on prior-turn reasoning; non-Claude
-models reject the ``reasoningText.signature`` field.
+models reject the ``reasoningText.signature`` field; OpenAI's reasoning GPTs (gpt-6) reject ``reasoningText``
+in assistant history outright.
"""
from __future__ import annotations
@@ -65,6 +66,9 @@ def _reasoning(blocks):
("global.moonshotai.kimi-k3", [], [{"text": "own sig_loop"}]),
# gpt-oss rejects reasoningText.signature: prior turns go back as readable text only.
("openai.gpt-oss-120b-1:0", [{"text": "own sig_prior"}], [{"text": "own sig_loop"}]),
+ # Reasoning GPTs reject readable reasoningText in assistant history outright (#140177): prior
+ # turns lose their reasoning; the in-flight loop still replays the model's own blocks.
+ ("global.openai.gpt-6.1-sol", [], [{"text": "own sig_loop"}]),
],
)
def test_converse_replays_each_models_reasoning_contract(model, prior, loop):