Skip to content

fix: save intermediate tool messages to prevent missing tool_result errors#459

Open
ahmed-sekka wants to merge 1 commit into2FastLabs:mainfrom
ahmed-sekka:fix/missing-tool-results
Open

fix: save intermediate tool messages to prevent missing tool_result errors#459
ahmed-sekka wants to merge 1 commit into2FastLabs:mainfrom
ahmed-sekka:fix/missing-tool-results

Conversation

@ahmed-sekka
Copy link
Copy Markdown

Summary

Fixes #396

When BedrockLLMAgent uses tools, the intermediate toolUse/toolResult conversation messages were only kept in a local list and never persisted to storage. This caused subsequent requests to fail with Bedrock validation errors about missing tool_result blocks.

  • BedrockLLMAgent now collects intermediate tool messages in tool_conversation during both single and streaming responses
  • Orchestrator saves these intermediate messages to storage alongside user input and final response
  • When max_recursions is exhausted, toolUse blocks are stripped from the response to prevent saving orphaned toolUse without toolResult

Test plan

  • Added unit tests for BedrockLLMAgent tool message collection (test_bedrock_llm_agent.py)
  • Added unit tests for Orchestrator intermediate message persistence (test_orchestrator.py)
  • Manual test: verify multi-turn conversations with tool-using BedrockLLMAgent + DynamoDBStorage no longer raise ValidationException

🤖 Generated with Claude Code

…rrors (awslabs#396)

When BedrockLLMAgent uses tools, the intermediate toolUse/toolResult
conversation messages were only kept in a local list and never persisted
to storage. This caused subsequent requests to fail with Bedrock
validation errors about missing tool_result blocks.

Changes:
- BedrockLLMAgent now collects intermediate tool messages in
  tool_conversation during both single and streaming responses
- Orchestrator saves these intermediate messages to storage alongside
  user input and final response
- When max_recursions is exhausted, toolUse blocks are stripped from
  the response to prevent saving orphaned toolUse without toolResult
@brnaba-aws
Copy link
Copy Markdown
Collaborator

Thanks for you PR, we will review it and provide feedback. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug?: Missing Tool Results

2 participants