diff --git a/python/src/agent_squad/agents/bedrock_llm_agent.py b/python/src/agent_squad/agents/bedrock_llm_agent.py index 9138cb8a..10552151 100644 --- a/python/src/agent_squad/agents/bedrock_llm_agent.py +++ b/python/src/agent_squad/agents/bedrock_llm_agent.py @@ -387,8 +387,8 @@ async def handle_single_response( if isinstance(item, dict) and "text" in item: content.append(item) - toolInUse=True - # Go through response content and save text items + toolInUse = False + # Go through response content and save toolUse items for item in response_content: if isinstance(item, dict) and "toolUse" in item: content.append(item) @@ -398,7 +398,7 @@ async def handle_single_response( if toolInUse: if thinking_content: content.insert(0,{"reasoningContent": thinking_content}) - else: + elif thinking_content: content.append({"reasoningContent": thinking_content}) kwargs = { @@ -520,8 +520,8 @@ async def handle_streaming_response( if isinstance(item, dict) and "text" in item: _content.append(item) - toolInUse=True - # Go through response content and save text items + toolInUse = False + # Go through response content and save toolUse items for item in response_content: if isinstance(item, dict) and "toolUse" in item: _content.append(item) @@ -531,7 +531,7 @@ async def handle_streaming_response( if toolInUse: if accumulated_thinking: _content.insert(0,{"reasoningContent": {"reasoningText": {"text": accumulated_thinking, "signature":thinking_signature}}}) - else: + elif accumulated_thinking: _content.append({"reasoningContent": {"reasoningText": {"text": accumulated_thinking, "signature":thinking_signature}}})