Skip to content

Conversation

@bipro1992
Copy link

@bipro1992 bipro1992 commented Jan 2, 2026

Description

Fix for Issue issue-78

This fixes the issue were currently The extract_agent_tools_used_from_messages function only captures the last tool used in a single assistant message when multiple tools are invoked. This occurs because the loop overwrites the tool variable instead of collecting all tools.

Related Issues

fixes #78

Documentation PR

N/A - no documentation changes needed

Type of Change

Bug fix

Testing

Verifed by testing tools_use_extractor with multiple tools. Multiple tools now appearing in trajectory

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

fix(issue-78): enhance tool usage extraction to support multiple tool…
@bipro1992 bipro1992 marked this pull request as draft January 2, 2026 05:38
@bipro1992 bipro1992 marked this pull request as ready for review January 2, 2026 05:38
bipro1992

This comment was marked as duplicate.

@bipro1992
Copy link
Author

bipro1992 commented Jan 2, 2026

@clareliguori Requesting for review

Copy link
Member

@cagataycali cagataycali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: ✅ LGTM

Great bug fix! The change correctly addresses the issue where multiple tool usages in a single assistant message were being overwritten.

What's Good:

  1. Correct Fix: Changed from overwriting tool to collecting all tools in a tools list, then iterating over each
  2. Test Coverage: Excellent test added (test_tools_use_extractor_extract_from_messages_with_multiple_tools) that validates the fix with:
    • Multiple tools in single assistant message (calculator + web_search)
    • Proper tool result matching by toolUseId
    • Verification of all tool properties
  3. Minimal Change: The fix is focused and doesn't introduce unnecessary changes

Minor Observation:

The inner loop variable shadows the outer message variable (line 25: for message in message_info). While this works correctly, consider renaming to content_block or content_item for clarity:

for content_block in message_info:
    if "toolUse" in content_block:
        tools.append(content_block.get("toolUse"))

This is a non-blocking suggestion - the current code works correctly.


Review by strands-coder autonomous agent 🤖

@cagataycali
Copy link
Member

🤖 Merge Readiness Check

Status: ⚠️ Almost Ready (CI Pending)

Criteria Status
Review Decision ✅ APPROVED
CI Status ⏳ PENDING
Mergeable ✅ No conflicts

This fix resolves a bug where multiple tool usages weren't being detected in the tools_use_extractor - directly addresses issue #78.

Recommendation: CI needs to run. Once CI passes, this PR is ready for merge.


Automated analysis by strands-coder 🤖

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] Multiple Tool Usage Not Detected in tools_use_extractor.py

2 participants