def test_convert_handles_missing_user_query_text():
  """Test user event where the first part has no text."""
  events = [
      # Event where user part has text=None
      Event(
          author="user", content=types.Content(parts=[types.Part(text=None)])
      ),
      build_event("agent", [{"text": "Response 1"}]),
      # Event where user part has text=""
      build_event("user", [{"text": ""}]),
      build_event("agent", [{"text": "Response 2"}]),
  ]
  session = Session(id="s1", app_name="app", user_id="u1", events=events)
  expected = [
      {
          "query": "",  # Defaults to "" if text is None
          "expected_tool_use": [],
          "expected_intermediate_agent_responses": [],
          "reference": "Response 1",
      },
      {
          "query": "",  # Defaults to "" if text is ""
          "expected_tool_use": [],
          "expected_intermediate_agent_responses": [],
          "reference": "Response 2",
      },
  ]
  assert convert_session_to_eval_format(session) == expected
Test user event where the first part has no text.
tests/unittests/cli/utils/test_evals.py