Skip to content

[BUG] Streaming chunks does not return complete boolean to signify end of stream #276

Open
@jer96

Description

@jer96

Checks

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

Strands Version

latest

Python Version

all

Operating System

mac/linux

Installation Method

pip

Steps to Reproduce

  1. Invoke a strands agent with stream_async
  2. Observe that no event is returned with complete == True

Expected Behavior

  1. It is expected that the agent will return a complete boolean to signify the end of the stream

Actual Behavior

    1. Observe that no event is returned with complete == True

Additional Context

Strands docs explicitly states that this is the correct API contract: https://strandsagents.com/latest/user-guide/concepts/streaming/async-iterators/?h=complete#event-types

However no events have this boolean attached to them.

Here is a sample of the final events of a request for the customer who encountered this bug:

{'data': '', 'delta': {'text': ''}, 'event_loop_metrics': EventLoopMetrics(cycle_count=2, tool_metrics={'get_skills': ToolMetrics(tool={'toolUseId': 'tooluse_VRlHZpAsRf60cvNz4lZHkg', 'name': 'get_skills', 'input': {}}, call_count=1, success_count=1, error_count=0, total_time=0.01149606704711914)}, cycle_durations=[0.9196999073028564], traces=[<strands.telemetry.metrics.Trace object at 0x7fb75e9aaa50>, <strands.telemetry.metrics.Trace object at 0x7fb75d9f6650>], accumulated_usage={'inputTokens': 1221, 'outputTokens': 236, 'totalTokens': 1457}, accumulated_metrics={'latencyMs': 1320}), 'agent': <strands.agent.agent.Agent object at 0x7fb75e9aae40>, 'event_loop_parent_span': None, 'event_loop_cycle_id': UUID('9bb554c7-d9c8-4bc0-8c3b-29add2f18b5c'), 'request_state': {}, 'event_loop_cycle_trace': <strands.telemetry.metrics.Trace object at 0x7fb75d9f6650>, 'event_loop_cycle_span': None, 'event_loop_parent_cycle_id': UUID('dfb845c6-6d8c-4d24-acd2-5c4156527ffe')}
{'event': {'contentBlockStop': {'contentBlockIndex': 0}}}
{'event': {'messageStop': {'stopReason': 'end_turn'}}}
{'event': {'metadata': {'usage': {'inputTokens': 704, 'outputTokens': 169, 'totalTokens': 873}, 'metrics': {'latencyMs': 873}}}}
{'message': {'role': 'assistant', 'content': [{'text': '<thinking> \nI have retrieved the list of possible employee skills using the "get_skills" tool. Now I will present this list to the user.\n</thinking>\n\nHere is the list of possible employee skills:\n\n1. Kotlin\n2. AWS\n3. Spring Boot\n4. Angular\n5. Docker\n6. React\n7. Git\n8. CI/CD\n9. REST API\n10. Machine Learning\n11. JavaScript\n12. DevOps\n13. GraphQL\n14. Node.js\n15. MongoDB\n16. TypeScript\n17. Java\n18. Python\n19. Kubernetes\n20. SQL\n\nIf you need more detailed information about any specific skill or a list of employees with particular skills, please let me know!'}]}}

Possible Solution

  1. The revised support for async iterators and events (driven by @pgrayy) may mitigate this.

Related Issues

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions