Skip to content

Conversation

@Unshure
Copy link
Member

@Unshure Unshure commented Oct 22, 2025

Description

Allow latest message to be a tool use

Related Issues

Closes #561

Documentation PR

N/A

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • 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

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- Add _has_tool_use_in_latest_message() helper function to detect ToolUse in latest message
- Modify event_loop_cycle() to skip model execution when ToolUse is detected
- Set stop_reason='tool_use' and use latest message directly for tool execution
- Add comprehensive test coverage with 10 test scenarios
- Maintain backward compatibility and existing functionality
- No performance impact, minimal overhead for detection

Resolves the requirement to skip model calls when the agent should directly
execute tools based on existing ToolUse messages in the conversation.

🤖 Assisted by the code-assist agent script
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Unshure Unshure marked this pull request as ready for review October 22, 2025 13:21
pgrayy
pgrayy previously approved these changes Oct 24, 2025
dbschmigelski
dbschmigelski previously approved these changes Oct 24, 2025
zastrowm
zastrowm previously approved these changes Oct 24, 2025
@Unshure Unshure dismissed stale reviews from zastrowm and dbschmigelski via cb41085 October 27, 2025 16:48
@github-actions github-actions bot added size/s and removed size/s labels Oct 27, 2025
@Unshure Unshure enabled auto-merge (squash) October 27, 2025 17:01
@Unshure Unshure merged commit 2147920 into strands-agents:main Oct 27, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Allow ToolUse as latest message

4 participants