Skip to content

strands.types.event_loop

Event loop-related type definitions for the SDK.

class Usage(TypedDict)

Defined in: src/strands/types/event_loop.py:8

Token usage information for model interactions.

Attributes:

  • inputTokens - Number of tokens sent in the request to the model.
  • outputTokens - Number of tokens that the model generated for the request.
  • totalTokens - Total number of tokens (input + output).
  • cacheReadInputTokens - Number of tokens read from cache (optional).
  • cacheWriteInputTokens - Number of tokens written to cache (optional).
class Metrics(TypedDict)

Defined in: src/strands/types/event_loop.py:26

Performance metrics for model interactions.

Attributes:

  • latencyMs int - Latency of the model request in milliseconds.
  • timeToFirstByteMs int - Latency from sending model request to first content chunk (contentBlockDelta or contentBlockStart) from the model in milliseconds.

Reason for the model ending its response generation.

  • “content_filtered”: Content was filtered due to policy violation
  • “end_turn”: Normal completion of the response
  • “guardrail_intervened”: Guardrail system intervened
  • “interrupt”: Agent was interrupted for human input
  • “max_tokens”: Maximum token limit reached
  • “stop_sequence”: Stop sequence encountered
  • “tool_use”: Model requested to use a tool