Skip to content

Python: Bug: AgentRunResponse.created_at returns local datetime labeled as UTC #2561

@larohra

Description

@larohra

Bug Description

The AgentRunResponse.created_at attribute returns a datetime value that represents the local server time, but it is labeled as UTC. This can cause confusion for users and integrations that rely on accurate UTC timestamps.

Sample Response (notice the Z at the end of created_at timestamp):

{
  "type": "agent_run_response",
  "messages": [
    {
      "type": "chat_message",
      "role": {
        "type": "role",
        "value": "assistant"
      },
      "contents": [
        {
          "type": "function_call",
          "call_id": "call_MF0TMK1KK5qmEO47SN1v88j0",
          "name": "calculate_tip",
          "arguments": "{\"bill_amount\":60,\"tip_percentage\":20}"
        }
      ],
      "author_name": "MathAgent",
      "message_id": "chatcmpl-Ci8awAB6jMUnuFhIQVlsf3l5mjPbp",
      "additional_properties": {}
    },
    {
      "type": "chat_message",
      "role": {
        "type": "role",
        "value": "tool"
      },
      "contents": [
        {
          "type": "function_result",
          "call_id": "call_MF0TMK1KK5qmEO47SN1v88j0",
          "result": {
            "bill_amount": 60.0,
            "tip_percentage": 20.0,
            "tip_amount": 12.0,
            "total": 72.0
          }
        }
      ],
      "author_name": "MathAgent",
      "additional_properties": {}
    },
    {
      "type": "chat_message",
      "role": {
        "type": "role",
        "value": "assistant"
      },
      "contents": [
        {
          "type": "text",
          "text": "A 20% tip on a $60 bill amounts to $12. The total bill, including the tip, is $72."
        }
      ],
      "author_name": "MathAgent",
      "message_id": "chatcmpl-Ci8aylrWJBB1zTR7yufJKe4PtuX0h",
      "additional_properties": {}
    }
  ],
  "response_id": "chatcmpl-Ci8aylrWJBB1zTR7yufJKe4PtuX0h",
  **"created_at": "2025-12-01T16:31:30.000000Z",**
  "usage_details": {
    "type": "usage_details",
    "input_token_count": 255,
    "output_token_count": 50,
    "total_token_count": 305
  },
  "additional_properties": {
    "system_fingerprint": "fp_b54fe76834",
    "logprobs": null
  }
}

But current UTC time - 2025-12-02T00:31:30Z

Steps to Reproduce

  1. Call an API or function that returns AgentRunResponse.
  2. Observe the value in the created_at field.
  3. Notice that while it indicates UTC, the actual time is the local server time.

Expected Behavior

The created_at field should return an accurate UTC datetime, or it should be labeled as local time if UTC is not used.

Actual Behavior

The timestamp claims to be in UTC, but the value is the local server time.

Impact

  • Timestamp misrepresentation can break downstream processing and analytics.
  • Could cause issues in distributed/multi-region systems.

Suggested Fix

Ensure that created_at is always returned in UTC if labeled as such or standardize the field's timezone labeling.


Please let me know if more context or logs are needed.

Metadata

Metadata

Labels

azure-functionsIssues and PRs related to Azure FunctionsbugSomething isn't workingpython

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions