Skip to content

[BUG] latencyMs returned by ollama provider is float type rather than int #2235

@paliwalvimal

Description

@paliwalvimal

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

v1.38.0

Python Version

3.13.12

Operating System

macOS Tahoe 26.4

Installation Method

pip

Steps to Reproduce

Use the below snippet to generate latencyMs metric:

from strands import Agent
from strands.models.ollama import OllamaModel

# Create an Ollama model instance
ollama_model = OllamaModel(
    host="http://localhost:11434",
    model_id="gpt-oss",
)

# Create an agent using the Ollama model
agent = Agent(
    model=ollama_model,
)

# Use the agent
result = agent("Tell me about Strands agents in 2 lines")

# Returns latencyMs as a float type
print(result.metrics.get_summary()["accumulated_metrics"])

ollama.py returns float formatted value whereas latencyMs as per Usage class requires value to be int. This raises validation error when used with pydantic for type checking. Error: Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=11441.835542, input_type=float]

Expected Behavior

Ollama model provider must return latencyMs as an int (11441)

Actual Behavior

Ollama returns float formatted value 11441.835542

Additional Context

No response

Possible Solution

Convert value to int type in ollama.py

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    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