OpenAIConverseConverter drops all but the first toolResult of a parallel tool call, and json results
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 76/100
Rechercherichtung
Read memory/integrations/strands/converters/openai.py, especially _bedrock_to_openai and message_to_payload, then compare its behavior with AgentCoreMemoryConverter. Reproduce the round trip using parallel toolResult blocks and a JSON result. Done means every result and its content survive restoration, consecutive tool messages are merged for Converse history, and the described reproduction passes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
With converter=OpenAIConverseConverter, a Strands agent that makes parallel tool calls stores only the first tool result. Strands puts every result of a parallel tool-use turn into one user message (strands/event_loop/event_loop.py:960), but _bedrock_to_openai (memory/integrations/strands/converters/openai.py, the if content and "toolResult" in content[0] branch) converts only content[0]. After restore, the assistant turn has N toolUse blocks and the next user turn has one toolResult, so the next Converse call fails the toolUse/toolResult pairing check (the same ValidationException class as #245).
It also keeps only text parts, so a tool result with a json block is restored as [{"text": ""}].
To Reproduce
from strands.types.session import SessionMessage
from bedrock_agentcore.memory.integrations.strands.converters.openai import OpenAIConverseConverter as C
def roundtrip(msg):
payload = C.message_to_payload(SessionMessage(message=msg, message_id=0))
events = [{"payload": [{"conversational": {"content": {"text": t}, "role": r.upper()}}]} for t, r in payload]
return [m.message for m in C.events_to_messages(events)]
results = {"role": "user", "content": [
{"toolResult": {"toolUseId": "t1", "status": "success", "content": [{"text": "sunny"}]}},
{"toolResult": {"toolUseId": "t2", "status": "success", "content": [{"json": {"temp_c": 21}}]}},
]}
print([b["toolResult"]["toolUseId"] for m in roundtrip(results) for b in m["content"] if "toolResult" in b])
# ['t1'] (AgentCoreMemoryConverter returns ['t1', 't2'])
A single result whose content is only {"json": {...}} comes back as [{"text": ""}].
Expected behavior
Every toolResult survives the round trip with its content, as with the default AgentCoreMemoryConverter.
Suggested fix
Emit one OpenAI role: "tool" message per toolResult (message_to_payload already returns a list), serialize json parts with json.dumps, and in events_to_messages merge consecutive restored tool messages back into one user message so the history keeps the alternation Converse requires.
Additional context
Reproduced on main. Not covered by #245 (default converter, different cause) or #718 (reasoning bytes only).
- Vorherrschende Sprache
- Python
- Sterne
- 786
- Forks
- 163
- Ø Merge
- 4 Std.
- Gemergte PRs (30 T.)
- 22
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws/bedrock-agentcore-sdk-python
-
bug high-severity
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainer antworten meist innerhalb von 1 Tag
-
OpenAIConverseConverter restores an empty history when one blob or text payload fails to parseOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
delete_all_long_term_memories_in_namespace deletes only the first 10 recordsEvtl. vergeben @Fire162 hat das vor 18 Tagen übernommen. Offenbug high-severity
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
aws/bedrock-agentcore-sdk-python#727 ·
Maintainer antworten meist innerhalb von 1 Tag
-
MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challengeEvtl. vergeben @abhiramshaji-cyber hat das vor 24 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
aws/bedrock-agentcore-sdk-python#702 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer indexEvtl. vergeben @citizen204 hat das vor 144 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
aws/bedrock-agentcore-sdk-python#556 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in aws/bedrock-agentcore-sdk-python
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
snap-stanford/Biomni#380 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
microsoft/playwright-python#3361 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation priority: low size: S status: needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation priority: low size: S status: needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
cubrid-lab/pycubrid#1307 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainer antworten meist innerhalb von 1 Tag