sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[BUG] LiteLLMModel - SageMaker Endpoints with TGI implementation do not emit tool_call as stop reason, breaking the agentic loop

Open dgallitelli opened this issue 1 year ago • 3 comments

Checks

  • [x] I have updated to the lastest minor and patch version of Strands
  • [x] I have checked the documentation and this is not expected behavior
  • [x] I have searched ./issues and there are no duplicates of my issue

Strands Version

0.2.0

Python Version

3.12.10

Operating System

Amazon Linux 2

Installation Method

pip

Steps to Reproduce

  1. Install Strands
  2. Deploy a SageMaker endpoint using TGI (I'm using Gemma 3)
  3. create a LiteLLMModel object pointing to the endpoint
  4. Attach any tool, e.g. calculator from strands_tools
  5. See it fail to call the tool (Timeout)

Expected Behavior

Expected behaviour is to actually call the tool successfully.

Actual Behavior

The agentic loop either stops with stop_reason == "end_turn" or times out as it keeps on waiting for the stop_reason tool call, which TGI containers with streaming output do not emit.

Additional Context

Image

Possible Solution

Check for stop_reason == "tool_call" OR len(tool_calls) > 0. This makes it much more generic and error resistant.

Related Issues

#271

dgallitelli avatar Jul 04 '25 12:07 dgallitelli

More details:

Image

dgallitelli avatar Jul 04 '25 12:07 dgallitelli

hi @dgallitelli thank your reaching out, is the the lack of stop_reason == 'tool_call SageMaker TGI endpoint-specific? Or is there planned support for this in the future? Given that this seems to be a divergence from the standard model specifications, we'd be hesitant to put a stop gap solution into Strands for one-off use cases, so it'd help to have more context on this.

jer96 avatar Jul 08 '25 19:07 jer96

Hey @jer96 , I ended up doing more testing and figured out it was a model-specific issue.

Il giorno mar 8 lug 2025 alle 21:08 Jeremiah @.***> ha scritto:

jer96 left a comment (strands-agents/sdk-python#354) https://github.com/strands-agents/sdk-python/issues/354#issuecomment-3050024811

hi @dgallitelli https://github.com/dgallitelli thank your reaching out, is the the lack of stop_reason == 'tool_call SageMaker TGI endpoint-specific? Or is there planned support for this in the future? Given that this seems to be a divergence from the standard model specifications, we'd be hesitant to put a stop gap solution into Strands for one-off use cases, so it'd help to have more context on this.

— Reply to this email directly, view it on GitHub https://github.com/strands-agents/sdk-python/issues/354#issuecomment-3050024811, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLMPMVFCE46JY3TGMYY7R33HQJMHAVCNFSM6AAAAACAZI735CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANJQGAZDIOBRGE . You are receiving this because you were mentioned.Message ID: @.***>

dgallitelli avatar Jul 08 '25 20:07 dgallitelli